关于链表的,帮我看看那里错误
#include<stdio.h>#include<stdlib.h>
struct student
{
long num;
float score;
struct student * next;
};
int n=0;//结点的个数
struct student * creat(void)
{
struct student * head;
struct student * p;
struct student * tail;
head=NULL;
p=(struct student *)malloc(sizeof(struct student));//开辟一个结点
scanf("%ld %f",&p->num,&p->score);
while(p->num!=0)
if(head==NULL)
head=p;//指向新的结点
//作为表尾的结点(最后的结点)
else
tail->next=p;//当前的最后一个结点指向新生成的结点
tail=p;
p=(struct student *)malloc(sizeof(struct student));
scanf("%ld %f",&p->num,&p->score);
}
return head;
}
main(){
struct student * head=create();
struct student * p=head;
while(p!=NULL)
{
printf("node[num=%ld,score=%f]\n",p->num,p->score);
p=p->next;
}
return 0;
}