struct node{
int data;
struct node *next;
};
main(){
struct node a,b,c,d;
struct node *s=&a;
a={10,&b};
b={10,&c};
c={10,&d};
d={10,NULL};
do{
printf("%d %d",(*s).data,(*s).next);
s=*s.next;
}while(*s.next!=NULL);
}
It is showing error at a={10,&b};Expression syntex error.please help.. thankzz in advance
Initialize the variable immediately:
struct node a={10,NULL};
And then assign the address:
a.next = &b;
Or use a compound literal:
a=( struct node ){10,&b}; //must be using at least C99
Initialization of a struct variable using only bracket enclosed list is allowed at definition time. use
struct node a={10,&b};
Otherwise, you've to use a compound literal [on and above c99
]
a=(struct node){10,&b};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With