C Programming language

adplus-dvertising
Operators in C Programming Language

  Storage Classes In C Language


Storage classes define the scope and lifetime of the variable and function within a C program.
Types of storage classes in C :

  • Auto storage class

  • Register storage class

  • Static storage class

  • Extern storage class

    Auto storage class
    : This is the default storage class for local variable.
    For example:

    {

    int num;
    auto int month;


    }

    Register storage class : This is used to define the local variable that should be stored in register instead of RAM.
    For example.
    {
    register int miles;
    }
    Static storage class : This is the default storage class for global variables.
    For example.
    {
    int num;
    static int count;
    main()
    printf(“%d”,count);
    }

    Extern storage class : Extern is used to give a reference of a global variable that is visible to all the program files.
    File 1: main.c


    int count=5;

    main()
    {
    write_extern();
    }
    File 2: write.c

    void write_extern(void);

    extern int count;

    void write_extern(void)
    {
    printf("count is %i\n", count);
    }
    Here extern keyword is being used to declare count in another file.