Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • Storage Classes in C

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 533
    Comment on it

    The storage class in C are the one which defines the scope or life time of the variable and functions

    Four Different storage classes of C are :

    • Auto 
    • Register
    • Static 
    • Extern

    Auto Storage Class 

    Auto storage class are the one which are default for local variables

    For example :


       int mount;
       auto int month;

    Register storage Class 

    The variables which are stored in registers instead of RAM they have Rigster Storage Class.

    Register storage classe defined only for them. The size of the variables then depands on the register size.

       register int  miles;


    If the variables are required frequent memory access then they are atored in the regiaters.Like counters.


    Static Storage classes

    The static storage classes are to keep the local variable scope in existence till the program execution ends, instead of creating and destroying each time variable is used.

    #include <stdio.h>
    void func(void);
    static int count = 5;
    main() {
       while(count--) {
       return 0;
    void func( void ) {
       static int i = 5;
       printf("i is %d and count is %d\n", i, count);

    The extern storage classes 

    It is used to give the reference to a global variable i.e., visible to all other files of the program files.

    When you use extern you cannot initialized the variable.



 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: