Every variable in c programming has two properties: type and storage class. Type refers to the data type of variable whether it is character or integer or floating point value etc. . Storage class determines how long it stays in existence. There are four types of storage class :
- automatic
- external
- register
- static
auto :
In the storage class auto , variables are declared inside the body of function. But in reality, variables with no storage class mentioned are automatic. These variables are known as local variables as they are only used in that function that means they are not used outside the function. Since, variable inside a function is automatic by default , auto variable is rarely used.
external:
external variables can be accessed by any function hence ,they are called as global variables. Variables declared outside every function are external variables.
register:
Register variables are similar to auto variables and exists inside that particular function only. Value stored in register are much faster than that of memory.
static:
The value of static variable persists until the end of the program. A variable can be declared static using keyword: static.
Leave a comment