关于C语言建立链表的问题,急(在线等待)

anfield 2002-10-03 04:58:38
关于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时出现不正常现象,这究竟是什么错误呢?
我下周要考《程序员》,急!!!!
...全文
43 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
lonely_wolf 2002-10-06
  • 打赏
  • 举报
回复
同意楼上的
jackiexzj 2002-10-03
  • 打赏
  • 举报
回复
没有包括输入输出流的头文件,加一条#include "stdio.h"应该就行了吧。
starflare 2002-10-03
  • 打赏
  • 举报
回复
你主函数有问题
anfield 2002-10-03
  • 打赏
  • 举报
回复
那应该怎么解决。我的程序有问题吗?
donghaish 2002-10-03
  • 打赏
  • 举报
回复
tc bug.

2,958

社区成员

发帖
与我相关
我的任务
社区描述
就计算机等级考试、软件初、中、高级不同级别资格考试相关话题交流经验,共享资源。
c1认证c4javac4前端 技术论坛(原bbs)
社区管理员
  • 软件水平考试社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧