|
发表于 2005-4-20 09:02:25
|
显示全部楼层
好像你用的是VS .NET吧。
你写的代码中去掉static。
我用
gcc version 2.96 20000731 (Red Hat Linux 7.3 2.96-110)
编译运行,结果仍是
1
1
Post by 锋锋
- #include <stdio.h>
- int * p=NULL;
- int test1(void)
- {
- int i = 1;
- p = &i;
- printf("%d\n",i);
- return(0);
- }
- int test2(void)
- {
- printf("%d\n",*p);
- return(0);
- }
- int main(void)
- {
- test1();
-
- test2();
-
- return(0);
- }
复制代码
结果为:
1
1
函数内static变量不是存储在“栈内存"中。汗一下... |
|