Because when str[i] hits a null ('\0', 0x00, %00, \000, 0) than it will break the loop, because it is 0. The middle statement is the check statement, like the portion inside a while(), execution occurs while it is non-zero.

Though kermit's latter example with the explicit compare to '\0' is clearer, having an implicit test for the '\0' character is a popular idiom in C and should be easily recognisable. The code could also be written as: