understanding the concept of a global variable [duplicate]
This question already has an answer here:
How can I access a shadowed global variable in C? 7 answers
If we have a variable "x" which is defined globally and another variable
with the same name "x" inside a function. when we print the value of "x"
why we always get the value which is assigned inside the function? Is
there any way we can print the global variable value.
int x=8;
void testCode()
{
int x=2;
printf("%d",x); //prints 2
}
No comments:
Post a Comment