/* CSE 333 Su12 Lecture 7 demo: static_extent.c */ /* Gribble/Perkins */ /* "static" local variables: normal scope, but lifetime is the */ /* lifetime of the program, not the lifetime of the function call. */ /* DON'T DO THIS unless you have a very, very good reason. */ #include void foo(void) { static int count = 1; printf("foo has been called %d times\n", count++); } void bar(void) { int count = 1; printf("bar has been called %d times\n", count++); } int main(int argc, char **argv) { foo(); foo(); bar(); bar(); return 0; }