In C programming language, every variable has a storage class which chooses lifetime, visibility and scope of that variable. The accompanying storage classes are most often used as a part of C programming language, What are the different storage types supported in c programming
- Static variables
- Automatic variables
- External variable
- Register variables
1. Static variables
The static storage class mostly instruct the compiler to keep a local variable in presence amid the life-time of the program as opposed to making and destroying it each time it comes into and leaves scope.
The static modifier may likewise be connected to global variables. At the point when this is done, it makes that variable’s degree be restricted to the scope in which it is proclaimed.
In C programming, when static is utilized on a class data part, it makes just a single duplicate of that part be shared by every one of the objects of its class.
2. Automatic variables
A variable proclaimed inside a function with no storage class specification is as a matter, of course, a automatic variable. They are made when a function is called and are pulverized consequently when the function exits. Automatic variables can likewise be called local variables since they are local to a function. Of course, they are appointed waste an incentive by the compiler.
3. External or Global variable
A variable that is declared outward any function is a Global variable. External variables stay accessible all through the whole program. One vital thing to recall about External variable is that their values can be changed by any capacity in the program.
4. The Register Storage Class
The register storage class is utilized to define local variables that ought to be put away in a register rather than RAM. This implies the variable has a maximum size equivalent to the register estimate (normally single word) and can’t have the unary “and” operator connected to it (as it doesn’t have a memory location).
The register ought to just be utilized for variables that require quick access, for example, counters. It ought to likewise be noticed that characterizing “register” does not imply that the variable will be put away in a register. It implies that it MIGHT be put away in a register depending upon hardware and execution restrictions.