for循环变量的作用域问题
niaucz opened this issue · comments
Niaucz commented
变量的作用域
链接文章结尾处的代码
for (int i = 0; i < 5; i++) {
int i = 999;
printf("%d\n", i);
}
printf("%d\n", i); // 非法
运行报错 error: redeclaration of 'int i'
老师想表达的是嵌套循环的作用域?
for (int i = 0; i < 5; i++)
{
for (int i = 0; i < 3; i++)
{
//...
}
}
Ruan YiFeng commented
你用的不是 GCC 吧。