如果我在 C 程序中使用未初始化的全局变量,会发生什么?这是未定义的行为吗?
#include <stdio.h>
int i;
int main()
{
while(i < 5)
{
i++;
}
printf("%d\n", i);
return 0;
}
最佳答案
Is it undefined behavior?
没有。
What happens?
i
具有静态存储持续时间(文件范围)。默认情况下它将初始化为零。
关于c - 使用未初始化的全局变量(用于读取和写入)可以吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44644721/