s1.c ==== #include /* Illustrates the features of the storage class static gcc -ansi s*.c -o s => s1.o, s2.o, s */ static int a = 4; /* global variable but local to this file */ void f1(void) { static int b = 6; ++a; ++b; printf("From f1: a = %d b = %d\n", a, b); } main() { extern int b; f1(); f1(); printf("From main-1: a = %d b = %d\n", a, b); f2(); f2(); ++b; printf("From main-2: a = %d b = %d\n", a, b); } Output: ======= From f1: a = 5 b = 7 From f1: a = 6 b = 8 From main-1: a = 6 b = 48 From f2: a = 29 b = 17 c = 75 From f2: a = 30 b = 18 c = 75 From main-2: a = 6 b = 49 s2.c ==== #include static int a = 28; /* global variable but local to this file */ int b = 48; /* global */ void f2(void) { static int b = 16; register int c = 75; ++a; ++b; printf("From f2: a = %d b = %d c = %d\n", a, b, c); }