Is there anyway of getting around the for loop scope without making the variable global?
For loop scope
Collapse
X
-
In C89 you have no choice, the loop variable has to be declared outside the loop. C99 added an option to localize the declaration to just the loop. I don't know that capabilities C++ has in that regard.Originally posted by boxfishIf you want a variable to be accesible outside of a for loop, then declare it outside of the for loop. It doesn't have to be global. It's local to the function that the for loop is in.Comment
Comment