I have two structure in c
struct data{
char *name;
};
struct lst{
struct lst *next;
struct table *data;
};
when I’m trying to assign a name like
l->data->name = d->name;
printf(“%s”,l->data->name);
it gives segmentation fault. So is it because read-only memory or caused by another reason ?
ok I solved the problem : )
I’ve done :
l->data = d;
d has the name already 🙂 thanks all
Just before you do that segmentation-violation-causing instruction, insert:
and see which one is set to NULL (or an invalid value).
Your segmentation violation is almost certainly caused by an uninitialized pointer.