关于动态链表的问题
这个程序哪里错误了,请高手帮忙啊 还没有完成,这是关于学生档案建立的,用链表#include<stdio.h>
#include<malloc.h>
#define null 0
int n;
int main(void)
{
struct student
{
long int num;
char a[20];
float Math,Eng,Sport,Biology,Chinese,Average;
struct student *next;};
struct student *head, *tail,*p,*p1;
printf("please input student's num,Name,Math Achievement,Eng Achievement,SportAchievement,Biology Achievement,Chinese Achievement.\n");
n=0;
tail=p=(struct student*)malloc(sizeof(struct student));
head=null;
scanf("%ld,%c,%f,%f,%f,%f,%f",&p->num,&p->a,&p->Math,&p->Eng,&p->Sport,&p->Biology,&p->Chinese);
while(p->num!=0)
{
n=n+1;
if(n==1){head=p;tail=p;}
else tail->next=p;
p=(struct student*)malloc(sizeof(struct student));
scanf("%ld,%c,%f,%f,%f,%f,%f",&p->num,&p->a,&p->Math,&p->Eng,&p->Sport,&p->Biology,&p->Chinese);
}
tail->next=null;
p1=head;
while(p1!=null)
{
p1->Average=((p1->Math)+(p->Eng)+(p1->Sport)+(p1->Biology)+(p1->Chinese))/5;
printf("%c Average is %f",&p1->a,p1->Average);
p1=p1->next;
}
return(0);
}