简单链表的创建和输出问题
#include<stdio.h>#include<stdlib.h>
#define NULL 0
#define LEN sizeof(struct student)
struct student
{
long num;
float score;
struct student *next;
};
int n;
struct student *create(void)
{
struct student *p1,*p2;
struct student *head;
n=0;
p1=p2=(struct student *)malloc(LEN);
scanf("%ld%lf",&p1->num,&p1->score);
head=NULL;
while(p1->num!=NULL)
{
n=n+1;
if(n==1)
{
head=p1;
}
else
{
p2->next=p1;
}
p2=p1;
p1=(struct student*)malloc(LEN);
scanf("%ld%lf",&p1->num,&p1->score);
}
p2->next=NULL;
return(head);
}
void print(struct student *head)
{
struct student *p;
printf("Now ,These %d records are:\n",n);
p=head;
if(head!=NULL)
do
{
printf("%ld%5.1f\n",p->num,p->score);
p=p->next;
}while(p!=NULL);
}
int main(void)
{
struct sutdent *head;
printf("input records:\n");
head=create();
print(head);
return 0;
} 错误如图,不知道怎样改啊,求指教