关于C语言建立链表的问题,急(在线等待)
关于C语言建立链表的问题:
请看以下C代码:
typedef struct student {
int num;
float score;
struct student *next;
}Stu;
struct student *creat(void){
struct student *head,*p1,*p2;
head=p1=p2=(struct student *)malloc(sizeof(Stu));
scanf("%d,%f",&p1->num,&p1->score);
while(p1->num!=0){
p1=(Stu *)malloc(sizeof(Stu));
scanf("%d,%f",&p1->num,&p1->score);
p2->next=p1;
p2=p1;
}
p2->next=0;
return(head);
}
struct student show(Stu *h){
Stu *p1;
p1=h;
do{
printf("num:%d,score:%f\n",p1->num,p1->score);
p1=p1->next;
}
while(p1->next!=0);
}
main(){
creat();
}
运行时,输入一组数值后,屏幕出现如下错误信息:
scanf : floating point formats not linked
Abnormal program termination
大概是说 scanf函数输入 float时出现不正常现象,这究竟是什么错误呢?
我下周要考《程序员》,急!!!!