l链表的问题
各位大侠帮我看看这个程序怎么出现这样的结果。#include<stdio.h>
#include<malloc.h>
struct student
{
int num;
char name[20];
float grade[4];
struct student *next;
};
struct student *creat()
{
struct student *p,*q,*head;
printf("请您输入各学生的学号,姓名,三科成绩及三科总分:\n");
printf("如果想结束输入请输入 0 结束:\n ");
p=(struct student *)malloc(sizeof(struct student));
scanf("%d,%s,%f,%f,%f,%f",&p->num,p->name,&p->grade[0],&p->grade[1],&p->grade[2],&p->grade[3]);
head=p;
while(p->num!=0)
{
q=(struct student *)malloc(sizeof(struct student));
printf("请您输入各学生的学号,姓名,三科成绩及三科总分:\n");
printf("如果想结束输入请输入 0 结束:\n ");
scanf("%d,%s,%f,%f,%f,%f",&q->num,q->name,&q->grade[0],&q->grade[1],&q->grade[2],&p->grade[3]);
p->next=q;
p=q;
}
p->next=0;
return head;
}
void print(struct student * head)
{
struct student *p;
p=head;
while(p!=0)
{
printf("%d %s %.2f %.2f %.2f %.2f\n",p->num,p->name,p->grade[0],p->grade[1],p->grade[2],p->grade[3]);
p=p->next;
}
}
void main()
{
struct student * head;
head=creat();
print(head);
}
我输入1,fdgdf,50,50,50,150
怎么输出这样的结果