</pre><pre name="code" class="cpp">void fun()
{
static int a=6;
printf("%d\t",a++);
}
void main()
{
fun();
fun();
}
输出结果为 6 7
去掉 static 结果为 6 6
static int c=10;
void foo()
{static int c=12; //静态局部变量在是在本函数内起作用,他的保留的值也只是在调用本函数的才有效
printf("%d ",++c);
}
int main()
{
printf("%d ",c++);//10
foo();//13
printf("%d ",--c);//10
return 0;
}