Storage Classes, register variables in C

Storage Classes

Storage classes of  C will provide following information to the compiler i.e.
1.Storage area of a variable.
2.Scope of a variable i.e. in which block that variable is visible.
3.Lifetime of a variable i.e. how long that variable will be there in active mode.
4.Default value of a variable if it not initialised.

Depend on storage area and behaviour, storage classes are classified into 2 types.
1. automatic storage class
2. static storage class

1] Automatic storage class
-Automatic storage class variables are created automatically and destroyed automatically.
-This storage class variable stored in stack area of Data segment.
-Under automatic storage class. we are having 2 types of storage class specifier auto, register.

2] Static storage class
-This storage class variables are created only once and throughout the program it will be there in active mode.
-Static storage class variable are stored in static area of data segment.
-Under static storage class we are having 2 types of static storage specifiers i.e. Static and extern.

Register variables

-It is special kind of variables which stores in CPU register.
-The basic advantage of register variable it it is faster than normal variables.
-In implementation, when we are accessing throught the program n no of times then go for register variable.
LIMITATIONS
-Register m/m is limited so it is not possible to create n no ofregister variables.
-On register variables we can't apply POINTERS because register variables doesn't allows to access the address.

Comments