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: 
You're running off the end of the array which invokes undefined behavior. One possible undefined behavior is that it works in a seemingly reasonable way. In this case probably what's happening is that the undefined behavior is padding your array with zeros.
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`.