由printf引发的runtime error

N年没碰printf这玩意了,今儿个遇上个悲剧问题

整个悲剧可以精简为一句代码的事

printf("%f", 4/2);

运行就有悲剧出来了

runtime error R6002

- floating point not loaded

 

貌似没见过这种错误

翻下MSDN查看R6002

 

Error Message
floating-point support not loaded

The necessary floating-point library was not linked.

To fix by checking the following possible causes

  1. 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.

  2. A format string for a printf_s or scanf_s function contained a floating-point format specification and the program did not contain any floating-point values or variables.

  3. 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.

  4. 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.

  5. 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.

看完为啥冒个runtime error出来也就释然了
将那句改为
printf("%f", (float) 4/2);

这样运行就不会有问题了
不过
如果你前面有过“正常”使用%f加载了浮点,运行时是不会有这样的错误的
只不过得不到正确的结果而已(整数除嘛)

看来要经常“温习”啊,不然什么基本的都忘光光了
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值