做了一个作业,但是编译的时候老是提示错误 "typedef struct student link;"中有太多的类型.请问这是怎么回事啊?
#define NULL 0 struct student { char num; char name; float Chinese; float English; float Math; struct student *next; } typedef struct student link; link *p; link *p1,*p2,*head ; void creat() { int n=0; head=NULL; p1=p2=(struct student *)malloc(sizeof(struct student)); printf("please input the number,name,Chinese score,English score,Math score."); scanf("%c,%c,%f,%f,%f,",&p1->num,&p1->name,&p1->Chinese,&p1->English,&p1->Math); if(p1->num!=0) n=n+1; head=p1; do { p1=(struct student *)malloc(sizeof(struct student)); printf("please input the number,name,Chinese score,English score,Math score."); scanf("%c,%c,%f,%f,%f,",&p1->num,&p1->name,&p1->Chinese,&p1->English,&p1->Math); p2->next=p1; p2=p1; n+=1; } while(p1->num!=0); p1->next=NULL; } void Outstudent() { p=head; do { printf("%c,%c,%f,%f,%f,",p1->num,p1->name,p1->Chinese,p1->English,p1->Math); p=p->next; } while(p->next!=NULL); } void Insert() { p1=(struct student *)malloc(sizeof(struct student)); printf("please input the number,name,Chinese score,English score,Math score."); scanf("%c,%c,%f,%f,%f,",&p1->num,&p1->name,&p1->Chinese,&p1->English,&p1->Math); p2->next=p1; p2=p1; p1->next=NULL;
} void Delete() { char m; struct student *p1,*p2; printf("please input the number of the student you want to delete."); scanf("%c",&m); p=head; if(p->num=m) head=p->next; else do { p1=p; p=p->next; p2=p->next; }while(p->num!=m); p1->next=p2; free(p); }
main() { int i; creat(); printf("please select an ability:1 for Outstudent,2 for Insert,3 for Delete;"); scanf("%d",&i); if(i=1) Outstudent(); else if(i=2) Insert(); else Delete(); }