Every variable must be declared before it can be used. The declaration determines the variable's type, its storage class, and possibly its initial value. The type of a variable determines how much space it occupies in storage and how the bit pattern it stores is interpreted. For example:
float dollars = 2.5F; // a variable of type float
dollars designates a region in memory
with a size of 4 bytes. The contents of these four bytes are
interpreted as a floating-point number, and initialized with the
The storage class of a variable determines its scope, its storage duration, and its linkage. The scope can be either block or file (see Section 1.2.4, earlier in this book). Variables also have one of two storage durations:
The variable is generated and initialized once, before the program begins. It exists continuously throughout the execution of the program.
The variable is generated anew each time the program flow enters the block in which it is defined. When the block is terminated, the memory occupied by the variable is freed.
The storage class of a variable is determined by the position of its declaration in the source file and by the storage class specifier, if any. A declaration may contain no more than one storage class specifier. Table 1-18 lists the valid storage class specifiers.
Table 1-18. The storage class specifiers
Variables declared with the ...