#include int b; void f1() { int a = 10; a++; printf("in f1: a = %d\n", a); } void f2() { b++; printf("in f2: b = %d\n", b); } char *f3(void) { static char str[20] = "a static variable"; /* Normally str would not live outside the function * it is a local variable for f3. However, static * will help us claim, the otherwise nonexistent value */ return(str); } int main(int argc, char *argv[]) { int a = 5; char *str = NULL; printf("Local variable a = %d\n", a); f1(); printf("After first call: a = %d\n", a); f1(); printf("After second call: a = %d\n", a); printf("\n"); b = 5; printf("Global variable b = %d\n", b); f2(); printf("After first call: b = %d\n", b); f2(); printf("After second call: b = %d\n", b); printf("\n"); printf("Before function call str = %s\n", str); str = f3(); printf("After function call str = %s\n", str); return 0; }