你能解释一下这个C程序的输出吗?我想问题是在printf("%d\n",t); 函数调用期间堆栈变坏了,因为我正在推动一个float但是正在阅读int.我不确定.
#include <stdio.h>
int main()
{
long x;
float t;
scanf("%f",&t);
printf("%d\n",t);
x=30;
printf("%f\n",x);
{
x=9;
printf("%f\n",x);
{
x=10;
printf("%f\n",x);
}
printf("%f\n",x);
}
x==9;
printf("%f\n",x);
}
Run Code Online (Sandbox Code Playgroud)
和输出
$ ./a.out
20.39
0
20.389999
20.389999
20.389999
20.389999
20.389999
$
Run Code Online (Sandbox Code Playgroud) c ×1