帮忙解释下输入元素后错误的原因。
#include<stdio.h>
#include<malloc.h>
#define NULL 0
#define LEN sizeof(struct xueji)
#define GESHI "%d%s%s%f%f%f%f%f"
struct xueji
{
int num;
char name[20];
char sex;
float english;
float chinese;
float math;
float computer;
float total;
struct xueji *next;
};
void *print(struct xueji *head)
{for(;head;head=head->next)
printf("%d%s%s%f%f%f%f%f",head->num,head->name,head->sex,head->english,head->chinese,head->math,head->computer,head->total);
return 0;
}
struct xueji *creat();
main()
{
struct xueji *head;
head=NULL;
printf("please input students` message and the enter a student NO.0.\n");
head=creat();
print(head);
return 0;
}
struct xueji *creat()
{
struct xueji *head,*p1,*p2,*p0;
p1=p2=(struct xueji *)malloc(LEN);
head=p1;
p1->next=NULL;
p0=p1;
scanf(GESHI,&p1->num,p1->name,&p1->sex,&p1->english,&p1->chinese,&p1->math,&p1->computer,&p1->total);
while(p0->num!=0)
{
p0=(struct xueji *)malloc(LEN);
scanf(GESHI,&p0->num,p0->name,&p0->sex,&p0->english,&p0->chinese,&p0->math,&p0->computer,&p0->total);
p1=head;
if(p0->num<p1->num)
{
head=p0;p0->next=p1;
}
else if(p1->next==NULL)
{
p1->next=p0;p0->next=NULL;
}
else
{
while(p0->num>=p1->num)
{
p2=p1;p1=p1->next;
}
p2->next=p0;
p0->next=p1;
}
}
return(head);
}
输入:5 asd t 5 8 9 3 4
回车后提示出现:floating point formates not linked
abnormal program termination