Loop Aids: continue and break

Normally, after the body of a loop has been entered, a program executes all the statements in the body before doing the next loop test. The continue and break statements enable you to skip part of a loop or even terminate it, depending on tests made in the body of the loop.

The continue Statement

This statement can be used in the three loop forms. When encountered, it causes the rest of an iteration to be skipped and the next iteration to be started. If the continue statement is inside nested structures, it affects only the innermost structure containing it. Let's try continue in the short program in Listing 7.9.

Listing 7.9 The skip.c program.
 /* skip.c -- uses continue to skip part of loop */ #include <stdio.h> ...

Get C Primer Plus®, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.