BlocksBlocks

包含在大括号 ({ }) 中的声明、定义和语句的序列称为“块”。A sequence of declarations, definitions, and statements enclosed within curly braces ({ }) is called a "block." C 中有两种类型的块。由一个或多个语句构成的语句“复合语句”(请参阅复合语句)是一种类型的块。There are two types of blocks in C. The "compound statement," a statement composed of one or more statements (see The Compound Statement), is one type of block. 另一种类型的块是“函数定义”,它由一个复合语句(函数的主体)和函数的关联的“标头”(函数名称、返回类型和形参)构成。The other, the "function definition," consists of a compound statement (the body of the function) plus the function's associated "header" (the function name, return type, and formal parameters). 一个块位于其他块中的情况称作“嵌套”。A block within other blocks is said to be "nested."

请注意,当所有复合语句包含在大括号内时,并非大括号内的所有内容都构成复合语句。Note that while all compound statements are enclosed within curly braces, not everything enclosed within curly braces constitutes a compound statement. 例如,虽然数组、结构或枚举元素的说明可出现在大括号内,但它们不是复合语句。For example, although the specifications of array, structure, or enumeration elements can appear within curly braces, they are not compound statements.

另请参阅See Also

源文件和源程序Source Files and Source Programs