Monday, September 23, 2013

Storage Classes in C

Today I am going to explain the most important concept of C language.
If you have gone through any interview , It is quite possible that you came across the questions like:

  • What do you mean by storage class in C?
  • How many storage classes are there in C?
  • Explain the different storage classes in C ?

So, I will be explaining the storage class concept in full detail with all its types.

Let us start by understanding What it means by a Storage class?

We know that Every variable posses the following property:

  • Lifetime: Lifetime of a variable defines "till what time we can access a particular variable". 
  • Scope: Scope of a variable defined "Where we can access a variable in our hundred and thousands lines of code".
  • Default value: what is the default value of the variable when it is only declared that is programmer has not assigned any value to it explicitly.
  • Storage place: Storage of a variable defined Where the variable is getting the memory to be accessed.

All the above properties are tied to the variables , and the specifiers consisting of these properties specify the storage class of a variable...

So, We can say that Storage class is an attribute/specifier which defines Lifetime,scope,storage and default value of a variable.

For defining different lifetime,scope,storage and default value the storage classes are categorized into 4 categories:

So, just by saying that this is an auto variable, a static variable , a extern variable or a register variable we are
telling about all the four properties of a variable.

Explanation of all the classes coming soon one by one.

No comments:

Post a Comment

Feel free to comment......