The switch statement allows you to jump to one of a number of numeric case labels depending on the value of an expression; it's more convenient than a long if/else chain. (However, you can use switch only when the expression is integral and all of the case labels are compile-time constants.)

The do/while loop is a loop that tests its controlling expression at the bottom of the loop, so that the body of the loop always executes once even if the condition is initially false. (C's do/while loop is therefore like Pascal's repeat/until loop, while C's while loop is like Pascal's while/do loop.)

Finally, when you really need to write ``spaghetti code,'' C does have the all-purpose goto statement, and labels to go to.

Read sequentially: prev next up top

This page by Steve Summit // Copyright 1995-1997 // mail feedback