Wednesday, 1 February 2012

Storage classes

Every variable in C or other language have two main features namely:
  1. Data Types
  2. Storage class
From C compiler's point of view, a variable name identifies some physical location within the computer where the string of bits representing the variable's value stored. There are basically two kinds of locations in a computer where such a value may be kept- Memory and CPU registers. It is the variable's storage class that determines in which of there two types of locations, the value is stored.
Moreover, a variable's  storage class tells us:
  1. Memory location i.e. where variable would be stored.
  2. Initial value or default value of variable
  3. What is scope of the variable
  4. What is life of the variable
Scope of variable:
Scope of variable i.e. in which function the value of the variable would be available.

Life of the variable:
The life of the variable i.e. how long would the variable exists.
There are four storage classes in C :

No comments:

Post a Comment