A storage class defines the scope (visibility) and life-time of variables and /or functions within a C program. They precede the type that they modify. We have four different storage classes in a C program-
a) auto
b) register
c) static
d) extern
The auto storage class
The 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 function, i.e, local variables.
The register storage class
The register storage class is used to define local variables that should be stored in a register instead of RAM. This means that the variables has a maximum size equal to the register size (usually one word) and can't have the unary '&' operator applied to it (as it not have a memory location).
{
register int miles;
}
The register should only be used for variables that require quick access such as counters . It should also be noted that defining 'register' does not mean that the variable will be stored in a register. It means that you t might be stored in a register depending on hardware and implementation restrictions.