vc中 scanf("%f",&f); 编译正确,运行出现debug error!!!

bluehawaii 2005-08-31 11:26:41
#include<stdio.h>

main()
{
float f;
scanf("%f",&f);
}
就这么简单,但是在vc中就出错
debug error
runtime error

但是f事先初始化以下就没有问题了 ,如f=0;
请问原因
...全文
812 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
zyfire88 2005-09-01
  • 打赏
  • 举报
回复
我在VC++下没问题啊
lujun-cc 2005-09-01
  • 打赏
  • 举报
回复
呵呵,我的也没有问题啊!

是不是和编译器的配置选项有关!
dadi0189 2005-09-01
  • 打赏
  • 举报
回复
那就晕了,如果这样的话,干脆我们定义这个变量的时候都初始化一个数。
这世界就是这样烦。
bugebear3 2005-08-31
  • 打赏
  • 举报
回复
改成double,还是要出错.必须要初始化先
zhouhuahai 2005-08-31
  • 打赏
  • 举报
回复
这个问题偶也遇到过,把f改成double就可以了.
jixingzhong 2005-08-31
  • 打赏
  • 举报
回复
浮点数据的支持问题,只要在 scanf 前面提供一个 浮点操作就可以了 ...
junguo 2005-08-31
  • 打赏
  • 举报
回复
在使用scanf得到float前,必须出现过float变量的值!

C Run-Time Error R6002
floating-point support not loaded
The necessary floating-point library was not linked.

Possible causes
The program was compiled or linked with an option, such as /FPi87, that requires a coprocessor, but the program was run on a machine that did not have a coprocessor installed.
A format string for a printf or scanf function contained a floating-point format specification and the program did not contain any floating-point values or variables.
The compiler minimizes a program's size by loading floating-point support only when necessary. The compiler cannot detect floating-point format specifications in format strings, so it does not load the necessary floating-point routines.
Use a floating-point argument to correspond to the floating-point format specification, or perform a floating-point assignment elsewhere in the program. This causes floating-point support to be loaded.
In a mixed-language program, a C library was specified before a FORTRAN library when the program was linked. Relink and specify the C library last.
xiaocai0001 2005-08-31
  • 打赏
  • 举报
回复
浮点数库链接的问题
bluehawaii 2005-08-31
  • 打赏
  • 举报
回复
难道没有人知道么
widowss 2005-08-31
  • 打赏
  • 举报
回复
vc下输入数据后报错,gcc编译并执行,没有报错
lxk_cool 2005-08-31
  • 打赏
  • 举报
回复
楼上的,奇怪,我也vc6下调试,编译没错,运行是出现runtime error,初始化后就没事了,或类型改成double
snowbirdfly 2005-08-31
  • 打赏
  • 举报
回复
对了~
我在Dev C++调试也没有错误~
snowbirdfly 2005-08-31
  • 打赏
  • 举报
回复
#include<stdio.h>

main()
{
float f;
scanf("%f",&f);
}
不对啊~
我在VC下面运行怎么没有错误~
搞笑~
是不是你的编译器有问题~~
qinxiaolin 2005-08-31
  • 打赏
  • 举报
回复
是浮点数库链接的问题吧,改成double 在我的机器上没问题了!`
jixingzhong(瞌睡虫(既然选择了远方,那就只有风雨兼程了!!))说的
scanf 前面提供一个 浮点操作就可以了..的方法 也可以

69,382

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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