Does C have scope hiding?
For example, if I have a global variable:
int x = 3;
can I 'declare' inside a function or main 'another' int x?
Yes, that's how C works. For example:
int x;
void my_function(int x){ // this is another x, not the same one
}
void my_function2(){
int x; //this is also another x
{
int x; // this is yet another x
}
}
int main(){
char x[5]; // another x, with a different type
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With