Storage Class

STORAGE CLASSES ● Storage classes are used to define the scope (visibility) and life-time of variables and/or functions ● Every variable and function in C has two attributes: type and storage class. ● There are four storage classes: • auto • static • extern or global • register THE AUTO STORAGE CLASS : The auto keyword is applied to all local variables automatically. It is the default storage class that is why it is known as automatic variable. EXAMPLE PROBLEM: #include<stdio.h> int main() { int a=10; auto int b=10;//same like above printf("%d %d",a,b); return 0; } Output: 10 10 The register storage class : ● Is used to define local variables that should be stored in a register instead of RAM ● Variable has a maximum size equal to the register size (usually one word) ● Can't have the unary '&' operator applied to it (as it does not have a memory location). { register int miles; } ● The register should only be used for variables that require quick ac...