# include <stdio.h> struct list { int num; list* next; 1 }; list* head=NULL; 2 list* create() 3 { list *p,*q; p=(struct list*)malloc(sizeof(struct list)); printf("input a integer:\n"); scanf("%d",&(p->num)); q=p; while(p->num!=0) { if(head==NULL) head=p; else q->next=p; q=p; p=(struct list*)malloc(sizeof(struct list)); scanf("%d",&(p->num)); } q->next=NULL; free(p); return(head); } void print(list* head) { while(head) { printf("\n%d",head->num); head=head->next; } } void main() { print(create()); }
程序创建一个链表,并把其中数据打印出来,编译后有三个错误: 1处的错误为Declaration missing ; . 2处的错误为Declaration syntax error . 3处的错误为Declaration syntax error . 请高手帮忙指正,谢了