【发布时间】:2013-07-28 12:01:10
【问题描述】:
# include <stdio.h>
int main()
{
int a=4;
printf("%f",a);
}
输出
0.000000
还有
# include <stdio.h>
int main()
{
float a=4.5;
printf("%d",a);
}
输出
0
谁能解释上述输出的行为? 我知道使用不同的覆盖规范是愚蠢的,但我只是为了理论上的目的。
【问题讨论】:
-
Unexpected output of printf() -
if type is not compatible with the type of the actual next argument (as promoted according to the default argument promotions), thebehavior is undefined
标签: c