Table of Contents
show
Auto Storage Class
- By default, an object whose identifier has block scope or local scope has auto storage class
- Auto specifies that the declared data object stored in main memory
- Specifies declared object will have automatic life time. The object will come into existence from the point of its declaration and remains into existence till the program control remains within the block in which it is declared
- The variables declared with auto storage class specification are not implicitly initialized. A variable declared with auto storage class specification has to be explicitly initialized. Otherwise, it will have a garbage value
- It is not possible to specify auto storage class specifier in the declarations that are made in the global scope
Example
#include<stdio.h>
#include<conio.h>
int main()
{
auto int a = 200;
printf("a = %d\n",a);
{
int b = 300;
printf("b=%d \n",b);
printf("Here a = %d \n",a);
}
printf("Now a = %d \n",a);
return 0;
}
Output
C:\TDM-GCC-64>gcc auto.c -o auto
C:\TDM-GCC-64>auto
a = 200
b=300
Here a = 200
Now a = 200
Views: 0