Professional Documents
Culture Documents
#include <stdio.h>
static int y;//global static variable
void main()
{
static int x;//local static variable
printf("%d %d",x,y);
show();
getchar();
getchar();
}
void show()
{
printf("%d %d",x,y);
}
//scope of x variable is within the block /within the function
//scope of y variable is thru out the program
//lifetime of static variable x,y is thru out the program
-----------------------------
#include <stdio.h>
static int y=10;//global static variable
void main()
{
static int y=20;//local static variable
printf("%d",y);//20
getchar();
getchar();
}
-----------------------------------------------------
Register storage class
1)keyword-->register
2)The variable declared with register keyword is called as register variable
3)register variable should not be declare globally
4)initial value is garbage
5)scope and lifetime will be within the block/within the function
6)NO linkage
7)stored on registers(AX,BX,CX----)
8)to access small amount of data at the faster rate
9)we cannot use & on register variable
10)registers are very limited,if sufficient memory is not availabe then
data will be shifted to PS.
-----------------------------------------------------------------------
Extern storage class/global variable
1)the variable declare with extern keyword is called as extern variable
2)global variable belongs to extern variable
3)initial value is 0
4)storage is data section
5)keyword-->extern
6)lifetime-->thru out the program
7)scope-->across the file
8)linkage-->external linkage
----------------------------------------------------------------