Tuesday, 28 August 2018

Storage Classes 1


Storage Classes are used to describe about the features of a variable. 


Basically there are four things that will decide the storage classes-

  • Default Value
  • Memory (Where it Stored)
  • Scope (Visibility)
  • Life
There are four storage classes in C Language are given bellow -
  1. Auto
  2. Static
  3. Extern
  4. Register 

Auto Storage Classes :- 

Default Value :- 
  • For local variable if we don't specify any storage type, then the compiler will treat that as auto .
  • All auto variable are local variable but we can not say all local variable auto variable.
Memory :-
  • Auto variable are present in function stack frame.
Scope :-
  • Scope of an auto is within a function or within block where it is declared.
Life :-
  • Life of an auto variable start when function execution start and ends when function execution ends.


Important Note :     
                              Re-Initialization is allowed for auto storage class. 
                              We should not catch Auto variable address while returning from the function.




Remaining storage classes will discuss in next post.