<分区>
代码段的o/p:
printf("%f", 9/5);
在我的 linux gcc 4.6.3 中(gcc myprog.c 后跟 ./a.out):
-0.000000
在 codepad.org 中:
2.168831
为什么不同?
我已经引用了链接:Why cast is needed in printf?和 Implicit conversion in C? , 但无法使用它。
关于键盘执行的信息: C: 海湾合作委员会 4.1.2 标志:-O -fmessage-length=0 -fno-merge-constants -fstrict-aliasing -fstack-protector-all
编辑: 更多的: 用于在(在同一程序中)键盘中执行以下操作
printf("%f\n", 99/5);
printf("%f\n", 18/5);
printf("%f\n", 2/3);
printf("%f\n%f\n%f", 2, 3, 4);
printf("%f\n", 2);
O/P 是
2.168831
2.168831
2.168831
0.000000
0.000000
-0.001246
-0.0018760.000000
前三个输出是相同的垃圾值(而不是最后一个)。想知道为什么。