Re: Exiting loop

break; http://msdn.microsoft.com/en-us/library/wt88dxx6%28VS.80%29.aspx

What the ? ?? The forum seems to have bugged out. I think my post overwrote the OP :o

if(condition 1) { for(condition2) //1st loop in if statement { .....Doing stuff here; if( condition 3) // if meet condition 3, break loop, back to start { break; } }//1st 'for' loop end

for(condition 4) //2nd loop in if statement { ....doing stuff here; if( condition 5) // if condition 5 meet, break loop, back to start { break; } }//2nd 'for' loop end } //if statement end

..................................................................... above are the flow of my sketch. I need to exit the 1st 'for' loop by forced using an if statement and jump to 2nd 'for' loop without exiting the if statement. Is there any advice/tips please?

Sorry smeezekitty, I just repost my statement

I think my post overwrote the OP

The person deleted the post. An annoyingly common problem.

In any case, break will do exactly what you want. break goes to the end, not the beginning. If you want to go to the beginning, you have to use goto.

If you want to go to the beginning, you have to use goto.

continue

break goes to the end

The break statement transfers control to the first statement AFTER the loop that it was used to break out of. It does not, technically, go to the end of the loop.

I need to exit the 1st 'for' loop by forced using an if statement and jump to 2nd 'for' loop without exiting the if statement.

This requirement does not make sense. Please explain the "without exiting the if statement" part.