struct Person{
char *name;
int numb;
char *var;
};
struct Node{
struct Person *data;
struct Node *next;
struct Node *prev;
};
int main() {
head=(struct Node*)(malloc(sizeof(struct Node)));//
tail=(struct Node*)(malloc(sizeof(struct Node)));//These two are global variables and they are initialized with null above.
struct Person *a1=(struct Person*)(malloc(sizeof(struct Person)));
char is[]="nameee";
strcpy(a1->name,is);
printf("%s\n",a1->name);
return 0;
}
why i am getting segmentation fault for that code? I created a doubly linked list stored Person but when i initialized the structure with a string this code is getting an error.