【发布时间】:2011-08-15 04:59:48
【问题描述】:
例如
#include<stdio.h>
int foo = 100;
int bar()
{
int foo;
/* local foo = global foo, how to implemented? */
return 0;
}
int main()
{
int result = bar();
return 0;
}
我认为在函数栏中,直接调用 foo 只会得到全局 foo。我如何参考当地的 foo?我知道在 C++ 中有这个指针。但是,C有类似的东西吗?
非常感谢!
【问题讨论】:
-
也许你可以参考 Ouah 的答案:stackoverflow.com/questions/12183899/…
标签: c global-variables scope local-variables