C examples for Language Basics:Variable
When a variable in the inner block has the same name with a variable in the outer block, the variable in the inner block shadows the variable in the outer block.
#include <stdio.h> int main(void) { int x;/* w w w.ja v a 2 s . com*/ x = 10; if (x == 10) { int x; /* this x hides the outer x */ x = 99; printf("Inner x: %d\n", x); } printf("Outer x: %d\n", x); return 0; }