Tuesday 1 October 2013

Storage Classes in C

Structure                                                                                                                    Preprocessor


Storage Classes in C:-defines the scope and lifetime of the variable.
 There are 4 types of storage classes in C

  • automatic
  • external
  • static 
  • register


1)automatic:- it is defined by the auto keyword.it is the default storage class for all the local variables only used with in the functions.

2)register:-if we define variable as register then it stores in the register instead of RAM. by which accessing of that variables is much faster than normal variables.

3)Static:-default storage class for global variables.static variables used throughout the program.and the value of static variables live throughout the execution.


4)extern:-it is used to give reference of a global variable i.e. visible to all program .
variables declared outside the function  known as extern variables.



No comments :

Post a Comment