C auto storage class

Automatic ( Auto ) storage class in C Programming

  1. This is default storage class
  2. All variables declared are of type Auto by default 
  3. In order to Explicit declaration of variable use ‘auto’ keyword
auto int num1 ;   // Explicit Declaration  
Features :
 Storage Memory
 Scope Local / Block Scope
 Life time
Exists as long as Control remains in the block
 Default initial Value
Garbage

Live Example :

void main()
{
auto mum = 20 ;
{
auto num = 60 ;
printf("nNum : %d",num);
}
printf("nNum : %d",num);
}

Output :
Num : 60
Num : 20

Note :
Two variables are declared in different blocks , so they are treated as different variables


Bookmark & Share