Hi
I came across this question in C++ Primer by Stanley Lippman.
int
main()
{
const char ca[] = {'h', 'e', 'l', 'l', 'o'};
const char *cp = ca;
while( *cp )
{
cout << *cp << endl;
++cp;
}
}
According to me, this code should produce indefinite result because of no specified null character at the end of the string, as the loop would continue until it finds a null character in any memory location.
But when I compiled the code, it runs for EXACLTY 13 times each times. WHy does the loop terminate after 13 iterations? OR Why is the null character present in the 13th memory location EACH TIME?
OR Im just wrong with my concepts, which I think I am.
Do help me.