Ok basically here are two examples one illustrating the use of break and one illustrating the use of continue:
Code:
int i,j;
for(i = 0;i < 10;i++){
for(j = 0;j < 10;j++){
if(i + j == 17) break;
}
/* on break control is returned here, just outside the innermost loop */
}
In the code above you have two simple nested for loops. When the condition inside the second for is true, control is returned right outside the innermost loop but inside the first one. (i.e. the i loop)
Code:
int i,j;
for(i = 0;i < 10;i++){
for(j = 0;j < 10;j++){
/* on continue control is returned here, after the loop variable has already been incremented
THE LOOP INDEX IS ONLY INCREMENTED AUTOMATICALLY IN FOR LOOPS */
if(i % j != 0) continue;
}
}
In short, break stands for Break from this loop and continue stands for continue the loop with the next iteration immediately, thus ignoring any additional instructions after the continue, inside the loop.
As an exercise try to come up with a similar example where you have a continue inside a single while loop. See what the difference is.