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

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 328
    Comment on it

    Storage classes are used to check the visibility and scope of the variables. There are 5 types of storage classes.

    auto storage class-> 

     the auto storage class is a default storage class and it  is for all local variables. Its scope is within the function.
    for example-> we declare any variable inside for loop so it's scope will be inside the loop only.

    register storage class-> 

    If we define any variable as register it means it will not be saved in the RAM , it will save in register. As they are not saving in any memory location so we don’t use & operator for it.
    register int  miles;

    we assign register keyword to those variables which require quick access.

    static storage class->

    static variables means that it will retain their values between the function calls. It is also known as class data member. If we declare any data as static so compiler will make only one copy of it and that would be shared by all the objects.
    Static keyword can be used with variables and methods. Static variables are persisted throughout the life of the program.

    static int count=5;

    extern storage class-> 

    extern is used to declare a global variable or function in another file.

    At the time when two or more files shares the same global variables or function, then we commonly use extern modifer.

     

    const storage class->

    const means once the value is declared to the variable then it will be the same throughout the program or we can say make it read only type.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
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: