Brief detail of Storage Classes

Auto Storage Class in C

The variables defined using auto storage class are called as local variables. Auto stands for automatic storage class. A variable is in auto storage class by default if it is not explicitly specified.

The scope of an auto variable is limited with the particular block only. Once the control goes out of the block, the access is destroyed. This means only the block in which the auto variable is declared can access it.

A keyword auto is used to define an auto storage class. By default, an auto variable contains a garbage value.

Example, auto int age;

The program below defines a function with has two local variables

int add(void) {
   int a=13;
   auto int b=48;
return a+b;}

We take another program which shows the scope level “visibility level” for auto variables in each block code which are independently to each other:

#include <stdio.h>
int main( )
  auto int j = 1;
    auto int j= 2;
      auto int j = 3;
      printf ( " %d ", j);
    printf ( "\t %d ",j);
  printf( "%d\n", j);}


 3 2 1

Leave a Reply

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