且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

while 循环中的变量声明 C/C++

更新时间:2022-06-11 21:40:00

检查条件的变量 i 是你在 main() 中声明的不是那个循环内.

The variable i that checks the condition is the one you declared in main() not the one inside the loop.

两者是不同的变量,您将它们混淆为一个,编译器不会像您一样容易混淆.

Both are different variables you are confusing them as one, the compiler doesn't get confused as easily as you were.

在循环内 i 指的是你在 { } 内但在 { 外声明的那个code>} i 指的是在 main()

Inside the loop i refers to the one you declared inside the { } but outside the { } the i refers to the one declared in main()