积家手表鉴定:结构体数组输入问题

来源:百度文库 编辑:高校问答 时间:2024/04/30 05:24:31
我定义一个结构提数组,想要对其进行输入操作,但程序提示出现异常而中断:scanf : floating point formats not linked
abnormal program termination
但当我将实型换为整型就能够进行输入操作!请高手指点!为什么用实型会出现上述错误.
程序为:
main()
{
int i;
struct stu
{
float score;
}stu[3];
for(i=0;i<3;i++)
scanf("%f",&stu[i].score);

}
chief_lfw:我看了你该的‘‘但还是不行‘‘

这是TC的一个BUG,它为了节省空间,默认使用的scanf函数不支持浮点数,你只需要在文件头
#include <math.h>
然后在main的里面加一句
sqrt(1.0); //没有什么作用,就是为了让TC打开浮点支持
还有,你的结构体定义放在main外边会好一点.

#include <math.h>
main()
{
int i;
struct stu
{
float score;
}stu[3];
sqrt(1.0); //这一句,让TC支持浮点操作
for(i=0;i<3;i++)
scanf("%f",&stu[i].score);

}

P.S:TC太古老了,还是换个编译器。