A storage class represent the visibility and location of a variable.

We can also say that it is used to describe the features of a variable/function. Storage classes in C is used to desrcibe the following things:

  • Variable scope
  • Location where the variable will be stored
  • Initialized value of a variable
  • Life-time of a variable and
  • Who can access the variable?

In short, we can say that it is used to represent the information about the variable.

Variable is associated with a data type, its value and also with the storage class.

Different types of storage classes

In C programming, we have four type of standard storage classes.

  1. Auto – It is a default storage class
  2. Extern – It is a global variable
  3. Static – It is a local variable and can return a value even when the control is transferred to the function call.
  4. Register – Variable which is stored inside a register.

Let us now understand them one by one in more detail.

Auto storage class in C

Variables defined using auto storage class are also called local variable. Variables are stored as auto storage class if it is not explicitly specified. The scope of auto variable is limited to the block in which it is declared. Outside the block, the access is destroyed. they are assigned a garbage value by default.

Leave a Reply

Your email address will not be published.