Storage Classes

5.11  Storage Classes

      Storage class specifiers

    Storage duration – how long an object exists in memory

    Scope – where object can be referenced in program

    Linkage – specifies the files in which an identifier is known (more in Chapter 14)

      Automatic storage

    Object created and destroyed within its block

   auto: default for local variables

auto double x, y;

   register: tries to put variable into high-speed registers

    Can only be used for automatic variables

register int counter = 1;

      Static storage 

    Variables exist for entire program execution

    Default value of zero

   static: local variables defined in functions. 

    Keep value after function ends

    Only known in their own function

   extern: default for global variables and functions

    Known in any function