The
The example above defines two variables with in the same storage class. '
The output of the above program would be:
auto
storage class is the default storage class for all local variables.
{
int mount;
auto int month;
}
The example above defines two variables with in the same storage class. '
auto
' can only be used within functions, i.e., local variables.Keyword | auto |
Storage | Memory (stack) |
Default Initial Value | An unpredictable value, which is often called a garbage value. |
Scope | Local to the block in which the variable is defined. |
Life | Till the control remains within the block in which the variable is defined. |
int main()
{
auto int i = 1 ;
{
auto int i = 2 ;
{
auto int i = 3 ;
printf ( "\n%d ", i ) ;
}
printf ( "%d ", i ) ;
}
printf ( "%d", i ) ;
return 0;
}
The output of the above program would be:
3 2 1
Related topics:
Overview of Storage Class in C | Register Storage Class in C | Static Storage Class in C | Extern Storage Class in C | Summary of Storage Class in C
List of topics: C Programming
No comments:
Post a Comment