The Automatic Storage Class

When the storage class of a variable is declared automatic(auto) it means:
-The variable is stored in memory
-The default value of the variable is auto which is unpredictable and often referred to as garbage.
-The scope of the variable is local only to the function in which it is declared
-The life of the variable is only till the control is in the block in which the variable is defined.

Example:
The following example shows how to declared the auto storage class of variables:
main()
{
auto int a,b;
printf("\na=%d\tb=%d",a,b);
}

A sample run of the program:
a=1140 b=249

No comments:

Post a Comment