I have the following struct -
struct data
{
unsigned char r;
int f;
};
I then try to print it but get a segmentation fault at the print statement. What am I doing wrong and how can I do the memcpy and print ?
struct data *data1;
char temp[10];
data1->r = 1; data1->f = 2;
memcpy(temp,(char *)(struct data *)data1, sizeof(struct data));
printf("buffer is %s\n",temp );