上面的代码的输出结果为什么是这样的
下面的代码的输出结果为什么是这样的
#include <stdio.h>
void main()
{
float a=1.2356;
int b;
b=(int)a;
printf("the a=%f,b=%f\n",a,b);
}
------解决方案--------------------
b 是整数, 要用 %d 来输出, 而不是 %f
#include <stdio.h>
void main()
{
float a=1.2356;
int b;
b=(int)a;
printf("the a=%f,b=%f\n",a,b);
}
------解决方案--------------------
b 是整数, 要用 %d 来输出, 而不是 %f