Dee*_*pak 1 c scope initialization declaration undefined-behavior
我只是在玩 for 循环并写了下面的代码。当我编写第二个 printf 语句时,编译器要求我再次声明 c 变量,当我再次声明它时,我运行代码并
得到 c + 4 的答案为 20。for 循环工作正常。为什么 c + 4 表达式产生输出 20?
#include<stdio.h>
int main()
{
for(int c =1; c <= 10; ++c)
{
printf("%d\n",c);
}
int c;
printf("%d ",c+4);
return 0;
}
Run Code Online (Sandbox Code Playgroud)