Question: Given the following code:

```
#include<iostream>
int main(){
  char container[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g'};
  for(char* cptr = container; *cptr != 0; cptr++)
    std::cout << *cptr << std::endl;
  return 0;
}

```

It prints these characters in sequence each time I execute it. I cannot understand why the loop would terminate since I have not explicitly specified any null terminator at the end of the container array. Please help.

Answer: 
It's just luck, really.

It happens that the area of memory corresponding to `container[7]` is 0, so you're getting lucky.

Exceeding the bounds of your array is undefined behavior. In your case, it just happens to be the behavior you were hoping for, but you can't rely on that.
You are evoking Undefined Behavior. Undefined Behavior means, "anything can happen," which includes, sometimes, exactly what you want to happen. That's what's happening here. 

The reason why you're invoking Undefined Behavior is because you are reading from uninitialized memory, when you access the element one-past-the-end of `container`.