wrote:
> i want to access the value of global variable inside the main function
> and inside the main func the var with the same name is available..
Ah, I didn't think of this. Another reply indicated one way of doing
this. However, this is purely academic, since if this situation ever
arose in practice you should rename one of your variables right away. In
short: don't ever give a global a name that might be reasonably used by
a local variable. If this results in large variable names, you can use
the #define/#undef trick:
int num_furry_bunny_suits = 2;
#define suits num_furry_bunny_suits
void foo(int i) {
suits += i;
return suits;
}
#undef suits
Cleaner but (sometimes) less efficient is a local pointer:
void foo(int i) {
int* suits = &num_furry_bunny_suits;
*suits += i;
return *suits;
}
--
Derrick Coetzee
I grant this newsgroup posting into the public domain. I disclaim all
express or implied warranty and all liability. I am not a professional.