Storage Classes in C

Variables in C not only have data types but also storage classes. The storage class provides information about the location of a variable. There are

basically two location where the variable value are stored: memory and CPU register. The variable's storage class decides in which of these location the

value is storage. The storage class of a variable tells us:
-where the variable would be stored
-the default initial value of the variable
(if the initial value has not been specifically assigned)
-the scope of the variable
(in which function the value of the variable would be variable)
-the life of the variable
The scope of the variable means over what part or parts of a program is the variable actually variable for use. The life of the variable is the

period during which the variable retain its value during the execution of the program.
Variables are also classified on the place of their declaration. Those variables which are declared within a particular function are local variable.

Those variables which are declared outside of any function are called global variables.
Storage classes explicitly declare the scope and life of the variables. These are useful mainly in multifunction and multiple file programs.
These are four storage classes in C:
-Automatic Storage Class
-External Storage Class
-Static Storage Class
-Register Storage Class

No comments:

Post a Comment