Storage Class in C

Storage Classes

Storage Classes in C

Storage Classes are used to describe the different features of variables and functions in C programming language.

These features mainly includes the following point.

  • The Scope of Variable.
  • The Lifetime of variable.
  • The location where the variable will be stored.
  • Initial value of Variable.
  • Who can access the variable or where the variable is accessible.


Storage classes in C

Types of Storage Classes

In C Programming Language there are four types of storage classes.

  1. Auto Storage Class
    •  This is the default storage class for all the variables declared inside a function or a block
    • There is no need for writing auto keyword while writing the C program.
  2. Extern Storage Class
    • Extern storage stands for external storage.
    • Extern means that variable is declared outside the block where it is used.
  3. Register Storage Class
    • Register storage class is almost same as auto storage class.
    • Register storage basically stores variable into CPU register rather than RAM for faster access.
  4. Static Storage Class
    • This storage class is used to declare static variables which are popularly used while writing programs in C language.
    • Static variables have a property of preserving their value even after they are out of their scope