Suppose you have two nested for loops like this:
int i, j; // Iterators
for(i=0; i<100; ++i) {
/* do some stuff */
...
for(j=0; j<99; ++j) {
/* do more stuff */
...
if( someFunction(j,i) == 2 ) {
/* break out of both loops */
}
}
}
Is there a way (similar to the break; command in just one loop) to end both loops on the spot?
You can use a
gotoas:or use another variable to control the loop iterations: