Block Scope Data Declarations

In C, a block scope data declaration can only be put at the beginning of a block. It describes a variable and makes that variable accessible to the current block. All block scope declarations that do not have the extern storage class specifier are definitions and allocate storage for that object.

You can declare a data object with block scope with any one of the following storage class specifiers:

If you do not specify a storage class specifier in a block-scope data declaration, the default storage class specifier auto is used. If you specify a storage class specifier, you can omit the type specifier. If you omit the type specifier, all variables in that declaration receive type int.

Initialization
You cannot initialize a variable declared in a block scope data declaration that has the extern storage class specifier.

The types of variables you can initialize and the values that uninitialized variables receive vary for that storage class specifier.

Storage
The duration and type of storage varies for each storage class specifier.

Declarations with the auto or register storage class specifier result in automatic storage duration. Declarations with the extern or static storage class specifier result in static storage duration.



Declarations Overview
File Scope Data Declarations
Declarators
Storage Class Specifiers
Initializers
Type Specifiers