7.1 Labeled Statements

A label is an identifier used to flag a location in a program as the target of a goto statement or switch statement. A label has the following syntax:

identifier : statement

   case constant-expression : statement
   default : statement

The scope of the label is the containing function body. Variables can have the same name as a label in the function because labels and variables have different name spaces (see Section 2.14).

There are three kinds of labeled statements in C:

The last two statements are discussed in Section 7.5.2 because they can appear only within a switch statement.


Previous Page | Next Page | Table of Contents | Index