|
发表于 2005-4-16 09:24:24
|
显示全部楼层
Post by 锋锋
- #include <stdio.h>
- int * p=NULL;
- int test1(void)
- {
- static 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变量不是存储在“栈内存"中。汗一下...
我记得cu上有过关于static,malloc等在哪儿分配内存的讨论 |
|