EDIT (undefined behavior)
Access to array elements outside the bounds of the array is undefined behavior.
Calling string functions with anything other than string C is undefined behavior.
Do not do that!
Line C is a sequence of bytes ending with a '\0'(a NUL terminator). All bytes must belong to the same object.
In any case, you see a coincidence!
But it can happen like this:
,------------------ garbage
| ,---------------- str[cnt] (when cnt == 4, no bounds-checking)
memory ----> [...|d|o|h|*|0|0|0|4|...]
| | \_____/ -------- cnt (big-endian, properly 4-byte aligned)
\___/ ------------------ str