HP C/iX Reference Manual (31506-90011)
Chapter 6 83
Statements
Compound Statement or Block
Compound Statement or Block
Compound or block statements allow you to group other statements together in a block of
code.
Syntax
compound-statement
::=
{
[declaration-list][statement-list]
}
declaration-list
::=
declaration
declaration-list declaration
statement-list
::=
statement
statement-list statement
Description
You can group together a set of declarations and statements and use them as if they were a
single statement. This grouping is called a compound statement or a block.
Except when declared as extern, variables and constants declared in a block are local to
that block and any subordinate blocks declared therein. If the objects are initialized, the
initialization is performed each time the compound statement is entered from the top
through the left brace ({) character. If the statement is entered via a goto statement or in
a switch statement, the initialization is not performed.
Any object declared with static storage duration is created and initialized when the
program is loaded for execution. This is true even if the object is declared in a subordinate
block.
Example
if (x != y)
{
int temp;
temp = x;
x=y;
y = temp;
}