There are three kinds of labels: identifier, case, and default.
Identifier label statements have the following form:
>>-identifier--:--statement------------------------------------><
The label consists of the identifier and the colon (:) character.
A label name must be unique within the function in which it
appears.
In C++, an identifier label may only be used as the target of a
goto statement. A goto statement can use a label before its
definition. Identifier labels have their own name space; you do not have
to worry about identifier labels conflicting with other identifiers.
However, you may not redeclare a label within a
function.
Case and default label statements only appear in switch statements. These labels are accessible only within the closest enclosing switch statement.
Case statements have the following form:
>>-case--constant_expression--:--statement---------------------><
Default label statements have the following form:
>>-default--:--statement---------------------------------------><
Examples of Labels
comment_complete : ; /* null statement label */ test_for_null : if (NULL == pointer)
Related References
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.