These storage classes are preceded by the data type There are 4 types of storage class.
- auto
- register
- static
- extern
eg:-
int number;
or
auto int number;
2. Register:- It is used to define local variables which will be stored in a register instead of RAM. This means that the variable has a maximum size which is equivalent to the register size .
it is used to make program execution faster.
eg:-
register int counter;
3.Static::- The static storage class instructs the compiler to keep a local variable in existence during the life-time of the program. Static storage class has its scope local to the function in which it is define,
The keyword used to define this storage class is static.
eg:-
static int var = 9
4.Extern:- Variables that are declared outside of all functions are known as external variables. External or global variables are accessible to any function.
It can be said that an extern variable is a global variable which is assigned with a value that can be accessed and used within the entire program.
eg:-
#include <stdio.h>
int val;
extern void funcGlobal();
main()
{
val = 15;
funcGlobal();
}
For more info click here