一个(结构体章节)问题
程序代码:
#include<stdio.h> #define LEN sizeof(struct student) struct student { long num; float score; struct student *next; }; int n; struct student *creat(void) { struct student *head; struct student *p1,*p2; n=0; p1=p2=(struct student *)malloc(LEN);//这里报错了!不知道为什么 scanf("%lf,%f",&p1->num,&p1->score); head=NULL while(p1->num!=0)//这里也报错了 { n=n+1; if(n==1)head=p1; else p2->next=p1; p2=p1; p1=(struct student *)malloc(LEN); } p2->next=NULL; return(head); }两处报错地方这样提示
高手来分析下!
还有n=n+1是++n 还是 n++
那个运行效率高?