C – Storage Class

After reading this storage class topic, you will understand its theory and you will able to implement it in C programming.

C Storage class deals with the storage location of the variable, the initial value of the variable, the life of variable and scope of the variable. Storage class also referred to “scope and lifetime of variable” in function.

Storage Class Types :

The four types of storage class in C language are:

  • Automatic storage class.
  • Register storage class.
  • Static storage class.
  • External storage class.

The storage class types are described below,

Storage ClassKeywordLifeInitial ValueStorage LocationScope
Automatic storage classautoTill the control persist within the block in which variable is declared.Garbage value Memory RegistersLocal i.e. within the block in which variable is declared.
Register storage classregisterTill the control persist within the block in which variable is declared.Garbage valueCPU RegistersLocal i.e. within the block in which variable is declared.
Static storage classstaticValue of variable remains same between different function calls.ZeroMemory RegistersLocal i.e. within the block in which variable is declared.
External storage classexternDuring the execution of programZeroMemory RegistersGlobal i.e. available to all the blocks of program.

 

 

Published by

Electrical Workbook

We provide tutoring in Electrical Engineering.

Leave a Reply

Your email address will not be published. Required fields are marked *