C Programming language

adplus-dvertising
Storage Classes in C Programming Language
Previous Home Next

Storage classes define the scope and lifetime of the variable and function within a C program.

Types of storage classes in C :

  1. Auto storage class : This is the default storage class for local variable.
    {
    	int num;
    	auto int month; 
    }
    
  2. Register storage class : This is used to define the local variable that should be stored in register instead of RAM.
    {
    	register int miles;
    }
    
  3. Static storage class : This is the default storage class for global variables.
    {
    	int num;
    	static int count;
    	main()
    	printf(“%d”,count);
    }
    
  4. Extern storage class : Extern is used to give a reference of a global variable that is visible to all the program files.
    int count=5;
    main()
    {
    	write_extern();
    }
    ////////////////////////
    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.

Previous Home Next