各位大神,请问我的动态链表程序怎么运行崩溃
#include <stdio.h>#include <stdlib.h>
#define LEN sizeof(struct Date)
struct Date
{
int num;
int score;
struct Date *next;
};
int n;
struct Date *creat(void)
{
struct Date *head;
struct Date *p1,*p2;
p1=p2=(struct Date *)malloc(LEN);
scanf("%d,%d",&p1->num,&p1->score);
n=0;
head=NULL;
while(p1->num!=0)
{
n=n+1;
if(n==0) head=p1;
else p2->next=p1;
p2=p1;
p1=(struct Date *)malloc(LEN);
scanf("%d,%d",&p1->num,&p1->score);
}
p2->next=NULL;
return(head);
}
int main()
{
struct Date *pr;
pr=creat();
printf("\nnum=%d\nscore=%d",pr->num,pr->score);
return 0;
}