Welcome

C Programming Tutorial


C Storage Class

     A Storage Class Specifier in the declaration modifies the linkage of the identifier declared, and storage duration of the corresponding objects.

  • auto
  • static
  • register
  • external

auto variables

      

static variables

       static keyword can be used on

  • Functions
  • Variables
    • Local Variables
    • Global Variables

Register variables

      Declaring a auto variable as a register variable,suggesting compiler that a variable be stored in processor register rather than in regular memory.

    register int x;

Limitations on register variable

  • Register keyword can be applied on local auto variables
  • Register variables works with number types only, not arrays or structures
  • It can't work with static or external Storage Class
  • declaring a pointer to register variable is an error

external variables

       extern keyword is used when global variables to be accessed in functions of same file(optional) or in another file

A variable declared outside of the function is called as Global variables. In order to access these variables in functions, programmer must specify extern keyword. extern keyword dictates/instructs the compiler to use external Linkage for these variables.

extern variables cannot have initializer, if it has it is an error

Linkage of Idenfiers

  • No Linkage
  • Internal Linkage
  • External Linkage

ADS