Variables in one area can mask variables in a higher area.
In this example, i defined inside the loop masks i defined outside. In the body of the loop, printf prints the value of internal i , which is 10. Then i++ runs again on internal i , setting it to 11.
When the loop goes to the bottom and comes back, the inner i goes beyond. Then the second and third for clauses act on the outer i . When the body of the loop is reintroduced, a new instance of internal i is defined and initialized to 10.
dbush source share