O'Reilly logo

Just Enough C/C++ Programming by Guy W. Lecky-Thompson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using break and continue

Recall the break keyword from the discussion of the switch . . . case conditional execution construct that you saw in Chapter 6. In that context it was used to exit the construct and resume normal program execution with the statement immediately following the closing brace of the switch code block. It usually followed a case statement in such instances.

The address book example from the counted loop section would also benefit from the break keyword. Rather than just storing the index of the found entry, you could choose to jump out of the loop and save a few cycles of precious processing time.

The break keyword has the same functionality inside a while loop—it stops execution. You could use a break statement to halt a ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required