#include<stdio.h>
//可以证明静态局部变量在被调用之前就已经进入内存了
int x = 3;
void f();
int main()
{
int* p = &x;
printf("%d\n", *p);
p++;
printf("%d\n", *p);
f();
printf("%d\n", *p);
return 0;
}
void f()
{
static int y = 555;
y = 666;
return;
}
全局变量和静态局部变量的内存挨在一起。
而且在第二个printf的时候我们就可以证明在f()未被调用的时候,静态局部变量y就已经存在了!!!