Tuesday, October 21, 2025

Storage Class in C

 Storage Class in C


            

The scope and lifetime of a variable or / and function within a C program is defined by storage class. There are four storage classes in C


auto -      It is the default storage class for all variables and / or   functions.


register - Allows for defining variables to store in CPU register  instead of RAM. Unary operator is not applied for register    variable.


static –   The static storage class allows the updated variable values  available  for the next time when the function, in which the  variable is defined,  is invoked for the next time.


extern -   It allows a global variable to be visible to all the program  files /  external files ( C programs).

     

No comments:

Post a Comment