Redefinition of the global variables in the inner scope

Let’s say we have the following:

char x; 
int main(){
int x = 5; // is this allowed? 
return 0


Yes, since this is in a new scope. The inner x shadows the outer x. Once the function ends, x again refers to the global char.

1 Like

2 posts were split to a new topic: Function re-declaration

A post was merged into an existing topic: Function re-declaration