关于vc里for循环变量的作用域的疑问,该如何处理
关于vc里for循环变量的作用域的疑问
#include <iostream.h>
void fn()
{
int array[10]= {1,2,3,4,5,6,7,8,9,0};
for (int count =0; count <10;count++)
cout < < array[count];
cout < <endl;
count++;
cout < <count < <endl;
}
void main()
{
fn();
}
运行结果:
1234567890
11
Press any key to continue
变量count 的作用域超出for循环了啊,who can tell me why ?
------解决方案--------------------
vc6不标准的,不要这样写,换个编译器就会出错
------解决方案--------------------
VC 对标准进行了“扩展”,
是“自定义”的那种扩展 ~
------解决方案--------------------
换 Dev C++······
BTW:
仰视一下小明 ....
#include <iostream.h>
void fn()
{
int array[10]= {1,2,3,4,5,6,7,8,9,0};
for (int count =0; count <10;count++)
cout < < array[count];
cout < <endl;
count++;
cout < <count < <endl;
}
void main()
{
fn();
}
运行结果:
1234567890
11
Press any key to continue
变量count 的作用域超出for循环了啊,who can tell me why ?
------解决方案--------------------
vc6不标准的,不要这样写,换个编译器就会出错
------解决方案--------------------
VC 对标准进行了“扩展”,
是“自定义”的那种扩展 ~
------解决方案--------------------
换 Dev C++······
BTW:
仰视一下小明 ....