They are 4 according to the visibility and life time of variable in a program.
Automatic
-------------
It is the default storage class in C.Here variable get focus while program reach the function and lose scope or visibility while program leave the Function . They are local to the function in which they are declared ie,The scope of the variable limited inside the function.We can use a keyword auto to declare these kind of variable.
Global
---------
Global variables are also called external variables.They are declared outside the main() at global declaration section.Or we can declare them using keyword extern.They can access anywhere from the program and by all functions. They have life time same as that of program.
Static
----------
Here we declare variables with the keyword static.These are local to function in which it is declared.They have life time same as that of program.The value hold by the static variable dn't flush until the programs execution ends.
Register
---------------
These storage class use for fast access of frequently used variables. They are declared with keyword register.The difference with other storage class is that they are stored in the cpu register which is a high speed memory location.
Monday, November 23, 2009
Subscribe to:
Posts (Atom)