Labeled Statements

Each statement in a program can be labeled. A label is an identifier added before the statement like this:

label_identifier: statement;

There is no special declaration of a label – it just “tags” the statement. Label_identifier has a function scope and the same label cannot be redefined within the same function.

Labels have their own namespace: label identifier can match any other identifier in the program.

A statement can be labeled for two reasons:

  1. The label identifier serves as a target for the unconditional goto statement,

  2. The label identifier serves as a target for the switch statement. For this purpose, only case and default labeled statements are used:

    case constant-expression : statement
    default : statement
Copyright (c) 2002-2012 mikroElektronika. All rights reserved.
What do you think about this topic ? Send us feedback!
Want more examples and libraries? 
Find them on LibStock - A place for the code