Code:#include<stdio.h> #include<malloc.h> struct snode{ int data; struct snode *next;} ; void begin(struct snode *head); void push(struct snode *head,int t); void pop(struct snode *head,int *d); void main(void){ struct snode *first; begin(first); int i,x; for(i=1;i<10;i=i+2){ push(first,i);} while(first->next!=NULL){ pop(first,&x); printf("%d",x);}} void begin(struct snode *head){ head=malloc(sizeof(struct snode)); head->next=NULL; } void push(struct snode *head,int t){ struct snode *p; p=malloc(sizeof(struct snode)); p->data=t; p->next=head->next; head->next=p;} void pop(struct snode *head,int *d){ struct snode *p; p=head->next; head->next=p->next; *d=p->data; free(p); }
When I compile the program above, it warned that in the line "begin(first)", "first"is used uninitialized in the function. But I have already declared as "struct snode *first".
What's my problem?