a. Storage Classes explanation

What is Storage Class in C?

A storage class represents the visibility and a location of a variable. It tells from what part of code we can access a variable. A storage class in C is used to describe the following things:

  • The variable scope.
  • The location where the variable will be stored.
  • The initialized value of a variable.
  • A lifetime of a variable.
  • Who can access a variable?

Thus a storage class is used to represent the information about a variable.

NOTE: A variable is not only associated with a data type, its value but also a storage class.

There are total four types of standard storage classes. The table below represents the storage classes in C.

Storage classPurpose
autoIt is a default storage class.
externIt is a global variable.
staticIt is a local variable which is capable of returning a value even when control is transferred to the function call.
registerIt is a variable which is stored inside a Register.

Different types of storage classes in C with examples-

  • Auto Storage Class in C
  • Extern Storage Class in C
  • First File: main.c
  • Second File: original.c
  • Static Storage Class in C
  • Register Storage Class in C

Leave a Reply

Your email address will not be published. Required fields are marked *