What is the scope of a while and for loop?
while
for
For example, if I declared an object within the loop, what is its behavior and why?
int a; for(int b=0; b<10; ++b) { int c; }
scopes as if it were:
int a; { int b=0; begin: if (b<= 10) { { int c; } ++b; goto begin; } }
The purpose is so that variables go out of scope at clearly defined sequence points.