Global Scope in C
-
I have a situation similar to following:
int b; int afunction() { int b = 0; ... }
I need to access global b in afunction?? C does not have :: operator. I cannot change the identifier of both local and global variable b. Is there a way around??:confused: ARSALAN MALIK -
I have a situation similar to following:
int b; int afunction() { int b = 0; ... }
I need to access global b in afunction?? C does not have :: operator. I cannot change the identifier of both local and global variable b. Is there a way around??:confused: ARSALAN MALIKArsalan Malik wrote: I need to access global b in afunction?? No, there is no such operator in C language. Arsalan Malik wrote: Is there a way around?? May be you can write a getter function for the global b. ;)
suhredayan
There is no spoon. -
I have a situation similar to following:
int b; int afunction() { int b = 0; ... }
I need to access global b in afunction?? C does not have :: operator. I cannot change the identifier of both local and global variable b. Is there a way around??:confused: ARSALAN MALIKArsalan Malik wrote: Is there a way around?? Yes, don't use
b
in both spots.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
-
I have a situation similar to following:
int b; int afunction() { int b = 0; ... }
I need to access global b in afunction?? C does not have :: operator. I cannot change the identifier of both local and global variable b. Is there a way around??:confused: ARSALAN MALIKTry this:- int b; int afunction() { extern int b = 0; ... }
-
I have a situation similar to following:
int b; int afunction() { int b = 0; ... }
I need to access global b in afunction?? C does not have :: operator. I cannot change the identifier of both local and global variable b. Is there a way around??:confused: ARSALAN MALIKTry this int b; int afunction() { int *ptr= &b; int b = 0; ..... }