CHAPTER 16

image

Storage Classes

Every variable has a storage class that determines its scope and lifetime. These storage classes include the following: auto, register, extern, and static. Each of these classes is also a keyword that can be placed before the data type to determine to which storage class a variable belongs.

Auto

The default storage class for local variables is auto, which can be explicitly specified with the auto keyword. Memory for automatic variables is allocated when the code block is entered and freed upon exit. The scope of these variables is local to the block in which they are declared, as well as any nested blocks.

int main(void) ...

Get C Quick Syntax Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.