动态链表,帮忙看下哪错了?
#include<stdio.h>#include<stdlib.h>
struct student
{
int num;
float score;
struct student *next;
};
struct student *head,*p1,*p2;
void main()
{
p1=(struct student *)malloc(sizeof(struct student));
scanf("%d,%f",&p1->num,&p1->score);
head=p1;
p2=head;
while(p1->num!=0)
{
p1=(struct student *)malloc(sizeof(struct student));
scanf("%d,%f",&p1->num,&p1->score);
p2->next=p1;
p2=p1;
}
p2->next=NULL;
while(p1!=NULL)
{
printf("%d,%f\n",p1->num,p1->score);
p1=p1->next;
}
}