Storage classes in c
To define a variable we need to mention not only its data type but also its storage class. Storage classes will tell the compiler, where the variable is stored and what will be its default value. In C, there are 4 different types of storage classes.
1. Automatic: The auto storage class is the default storage class for all local variables.
2. Register: The register storage class is used to define local variables to be stored in a register instead of RAM.
3. Static: The static storage class instructs the compiler to keep a local variable in existence during the life-time of the program. Therefore, making local variables static allows to maintain their values between function calls.
4. External: The extern storage class is used to give a reference of a global variable that is visible to ALL the program files.
|2.||Default value||Garbage value||Garbage value||0||0|
Uses register storage class very often because there are very few CPU registers and many of them might be busy.