There are four storage classes in C, which are following -
auto - Storage Class
auto is the default storage class for all local variables.
{
int Count;
auto int Month;
}
The example above defines two variables with the same storage class. auto can only be used within functions, i.e. local variables.
register - Storage Class
register is used to define local variables that should be stored in a register instead of RAM. This means that the variable has a maximum size equal to the register size (usually one word) and cant have the unary '&' operator applied to it (as it does not have a memory location).
{
register int Miles;
}
Register should only be used for variables that require quick access - such as counters. It should also be noted that defining 'register' goes not mean that the variable will be stored in a register. It means that it MIGHT be stored in a register - depending on hardware and implimentation restrictions.
Static - storage class
The keyword used for Static storage class is 'static'. The variable declared as static is stored in the memory. Default value of that variable is zero. Scope of that variable is local to the block in which the variable is defined. Life of variable persists between different function calls.
External - storage class
The keyword used for External storage class is 'extern'. The variable declared as extern is stored in the memory. Default value of that variable is zero. Scope of that variable is global. Variable is alive as long as the program’s execution doesn’t come to an end.