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 Class | Keyword | Life | Initial Value | Storage Location | Scope |
---|---|---|---|---|---|
Automatic storage class | auto | Till the control persist within the block in which variable is declared. | Garbage value | Memory Registers | Local i.e. within the block in which variable is declared. |
Register storage class | register | Till the control persist within the block in which variable is declared. | Garbage value | CPU Registers | Local i.e. within the block in which variable is declared. |
Static storage class | static | Value of variable remains same between different function calls. | Zero | Memory Registers | Local i.e. within the block in which variable is declared. |
External storage class | extern | During the execution of program | Zero | Memory Registers | Global i.e. available to all the blocks of program. |