What Narue says is entirely correct.
>>WHy does the loop terminate after 13 iterations?
Your stack-frame will look like this: 8 bytes for the char-array (ca) (aligned at 4 bytes, since it needs 5 bytes, it will take up 8 bytes as the smallest multiple of 4 bytes), and 4 bytes for the char-pointer (cp), that makes 12. Your compiler probably fills the stack-frame with some special value (used while debugging), so you hit a 0 only when you reach the end of the stack-frame. But I don't know why the byte after the end of the stack-frame is always zero, that's why they call this undefined behavior. For instance, on my computer, it always stops just after the end of the char-array, as if it was a null-terminated string.
Undefined behavior really just means that there is no way to be sure what will happen, all bets are off. But understanding why it can behave in certain ways is good, because it might help you to recognize the symptoms if you have code with such a problem.