C language 4 storage classes : auto, extern, static, register

In C language four storage classes, namely
1. auto
    • This is the default storage class for all the variables. Auto variables can be only accessed within the block/function.
2. extern
    • the variable is defined elsewhere and not within the same block where it is used, this can be overwritten in a different block as well. So an extern variable is nothing but a global variable.
3. static
    • initialized only once and exist till the termination of the program, Their scope is local to the function to which they were defined.
4. register
    • declares same functionality as that of the auto variables, difference is that the compiler tries to store these variables in the register of the microprocessor.

Leave a Comment

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