The code below runs. It is whittled down from a much larger program that was behaving strangely. When the malloc line is removed the strcpy line causes a segmentation fault at run time. I think it is because of the structure nvdat. I don't understand why the structure would require the malloc line.
TIA. Bill S.
Code:
#include <stdio.h>
#include <string.h>
#include <malloc.h>
char buf1[90] = "7";
char buf2[90] = "8";
struct nvdat {
char *bf[90];
} k[10];
int main()
{
memmove(buf2, buf1, 3);
if ((k[0].bf[0] = malloc(20)) == NULL)
printf("malloc error");
strcpy(k[0].bf[0], buf2);
printf("%5s \n",k[0].bf[0]);
}