Listing 4 Avoiding a compiler error
(a). /* This code will cause a compile error */ void main(void) { int i = 10; printf("i: %d\n", i); int j = 100; /* This statement will cause a compiler error since it was not declared at the top of the function. */ printf("j: %d\n", j); } (b). /* whereas this code will not */ void main(void) { int i = 10; printf("i: %d\n", i); { int j = 100; /* This statement is fine since it is akin to defining a local function within the function. */ printf("j: %d\n", j); } }