Course Content
Programming Language C
About Lesson
 
Storage Classes in  C
Storage Class
auto
static
register
extern
by default when we declare a variable belong to auto storage class
static int x;
 

 

 
C
#include<STDIO.H>
void msg();
int main()
{
    msg();
    msg();
    msg();
}
void msg()
{
    static int x=1; 
    printf("\nX=%d",x);
    x++;
}
/*
X=1
X=1
X=1
Static variable preserve itsself last value in multiple function call

*/
ClassLocationDefault ValueScopeLife
autoRAMGarbageinside blockinside block
staticRAM0inside blockuntil end of program
registerCPU REGISTERGarbageinside blockinside block
externRAM0whole program (Global)until end of program