C语言问题, 请帮个忙,指出问题在那里, 十分感谢~

来源:百度知道 编辑:UC知道 时间:2024/05/13 13:05:16
代码如下,
#include "stdio.h"

main()
{
struct student
{int num;
float score;
struct student *next;
};
struct student p,*p1=&p;
scanf("%d%f",&p1->num,&p1->score);
printf("%d %f",p1->num,p1->score);

}
就想在成员里输入一个整数和一个实数,可是当我输入第一个数时,程序就停止输入, 屏幕上显示“floating point formats not linked
abnormal programme termination”,
就搞不懂是什么问题?

用TC-2.0系统编写小的C程序,如果程序里用到浮点输入,有时运行中会出现下面错误信息:

scanf : floating point formats not linked
Abnormal program termination

这个错误信息的意思是:scanf的浮点格式转换程序没有连接。

TC开发时(80年代)DOS下的存储资源紧缺,因此TC在编译时尽量不加入无关部分。在没发现需要做浮点转换时,就不将这个部分安装到可执行程序里。但有时TC不能正确识别实际确实需要浮点转换,因此就会出现上面错误。

解决方法:设法告诉TC需要做浮点数输入转换。下面例子里增加了一个double变量并用它输入。

大程序里由于变量很多,只要有了线索,TC就会把浮点转换连上,因此反而不常遇到这个问题

#include "stdio.h"

main()
{
struct student
{int num;
float score;
struct student *next;
};
struct student p,*p1=&p; float x;//增加个x中转
scanf("%d%f",&p1->num,&x);
p1->score=x; //这样就可以了
printf("%d %f",p1->num,p1->score);

}

没问题啊 我用TC和VC都试过了 可以正常运行