Storage class is a location, scope or longevity specifier of a variable.
- There are four different storage-class specifications:
auto int a;
Initialization: Not done by the compiler automatically, to be done by the programmer.
Scope: Confined to a single function in which it is declared.
The variable automatically created and destroyed within a function is called Automatic variable. That means an automatic variable does not retain its value once control is transferred out of its defining function. The default storage class of a variable declared inside a function is automatic. That is why the keyword auto is not required at the beginning of each variable declaration. The automatic variable is also referred to as local or internal variable.
extern int a;
Initialization: Done by the compiler automatically to 0, if not done by the programmer.
Scope: Extends from the point of declaration through the remaining part of the program.
The variable that is recognized globally and can be accessed from any function that falls within its scope is called External variable or Global variable. This implies that an external variable declared somewhere…
I would like to learn more!