Auto Storage Class In C Language

Storage Class Definition

Storage class in C decides the part of storage to allocate memory for a variable, it also determines the scope of a variable.

All variables defined in a C program get some physical location in memory where variable's value is stored.

The storage class of a variable in C determines the life time of the variable if this is 'global' or 'local'.


Auto Storage

A variable defined within a function or block with auto specifier belongs to automatic storage class.

All variables defined within a function or block by default belong to automatic storage class if no storage class is mentioned.

A variables having automatic storage class are local to the block which they are defined in, and get destroyed on exit from the block.

Example:



Output:

 
 garbage garbage garbage 


Read Also: