STORAGE CLASSES IN C LANGUAGE

STORAGE CLASSES IN C LANGUAGE

In this article we’ll study about STORAGE CLASSES IN C LANGUAGE. There are various type of STORAGE CLASSES IN C LANGUAGE. There are basically two kinds of location where value can be store. Memory and CPU registers. Then, It is the variable’s storage class that determines in which of the two types of locations the value is store.

TYPES OF STORAGE CLASSES:

There are four types of storage classes which are given below

  • Automatic storage class.
  • Register storage class.
  • Static storage class.
  • External storage class

Further we’ll discuss the above classes on the basis of four characteristic. First Storage. Then Second Default initial value. Next Scope and then fourth Life.

AUTOMATIC STORAGE CLASS:

Their storage is in memory. Their default initial value is an unpredictable value. Which is also call as garbage value. Its life is till the control remains within the block. In which the variable is define. Keyword for this storage class is auto. And also its scope is local to the block. In which the variable is defined.

REGISTER STORAGE CLASS:

Its storage is in CPU registers. Default initial value is also garbage value. Its scope is also local to the block . where the block is define. Life of this class is till the control remains within the block. Where the variable is define. Sometime, as CPU registers are limited. And they may be busy doing other task. Then the variable work as if storage class is auto.

STATIC STORAGE CLASS:

Its storage is in memory. Default value is 0(zero). Its scope. Its scope is also local to block . In which variable is define. And its life is value of the variable persist between different function calls. Then The difference between state and static and auto storage class is that static variable’s don’t disappear. When the function is no longer active. Their values persist. If the control come back to the same function again.

EXTERNAL STORAGE CLASS:

Its storage is in memory. Default initial value is zero. Its scope is global. Its life is as long as the program’s execution doesn’t come to end. A variable declared outside of function also work as extern variable without declaring it. If variable is declared globally . And within a function declared locally, preference will be given to local variable.

Previous article

for more detail on this article