#include <stdio.h>
static int a =0;
void fun1()
{
a++;
printf("a %d\n",a);
}
void fun2()
{
static int b = 0;
b++;
printf("b %d\n", b);
}
int main()
{
fun1();
fun1();
fun1();
fun2();
fun2();
fun2();
return 0;
}
gcc 编译运行结果:
a 1
a 2a 3
b 1
b 2
b 3
static特性可见一斑。