HPlogo HP-UX/HP C Compiler: HP C/HP-UX Reference Manual > Chapter 6 Statements

Labeled Statements

» 

Technical documentation

Complete book in PDF

 » Table of Contents

Syntax

labeled-statement ::=
identifier : statement
case constant-expression : statement
default: statement

Description

Labeled statements are those preceded by a name or tag. You can prefix any statement using a label so at some point you can reference it using “goto ” statements. Any statement can have one or more labels.

The case and default labels can only be used inside a “switch ” statement.

Example

if (fatal_error)
goto get_out;
. . .
get_out: return(FATAL_CONDITION);

The return statement is labeled get_out.

© Hewlett-Packard Development Company, L.P.