N年没碰printf这玩意了,今儿个遇上个悲剧问题
整个悲剧可以精简为一句代码的事
printf("%f", 4/2);
运行就有悲剧出来了
runtime error R6002
- floating point not loaded
貌似没见过这种错误
翻下MSDN查看R6002
The necessary floating-point library was not linked.
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_s or scanf_s 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.
看完为啥冒个runtime error出来也就释然了 将那句改为 printf("%f", (float) 4/2); 这样运行就不会有问题了 不过 如果你前面有过“正常”使用%f加载了浮点,运行时是不会有这样的错误的 只不过得不到正确的结果而已(整数除嘛) 看来要经常“温习”啊,不然什么基本的都忘光光了