|
VMS Help CC, Language topics, Block *Conan The Librarian |
A block is a compound statement. It allows more than one statement
to appear where a single statement ordinarily is used. It is made
up of a list of declarations and statements, enclosed in braces:
{ [declaration ...] [statement ...] }
The declaration list is optional; if it is included, all
declarations of variables are local to the block and supersede
previous declarations for the duration of the block. A block is
entered normally when control flows into it, or when a goto
statement transfers control to a label at the beginning of the
block. Each time the block is entered normally, storage is
allocated for auto or register variables. If, on the other hand, a
goto statement transfers control to a label inside the block or if
the block is the body of a switch statement, these storage
allocations do not occur. Blocks can be used wherever single
statements are valid -- for example, as the action clause of an if
statement:
if ( i < 1 )
{ /* BEGINNING OF BLOCK */
char x;
for (x = 'a'; x <= 'z'; x++)
printf("char = %c\n", x);
} /* END OF BLOCK */
|
|