Storage Classes
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:
- Static storage duration
The variable is generated and initialized once, before the program begins. It exists continuously throughout the execution of the program.
- Automatic storage duration
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.
|
Specifier |
Meaning |
auto |
Variables declared with the storage class specifier
|
register |
The storage class specifier |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access