First, the code you posted has a horrible bug: cptr != 0 should be *cptr != 0. You should be checking to see if the character at the given address is null, not if the pointer itself is null.
The other answers and comments are correct. The only reason you're getting the correct output is because there happens to be some zeroed memory right at the end of your container array. Putting the container array inside a struct will help to eliminate the extra padding the compiler might otherwise insert:
#include<iostream>
int main(){
struct {
char container[7];
char alphabet[27];
} x = {
{'a', 'b', 'c', 'd', 'e', 'f', 'g'},
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
};
for(char* cptr = x.container; *cptr != 0; cptr++)
std::cout << *cptr << std::endl;
return 0;
}
If you run this version you'll see your array 'a'–'g' printed, then it will run over into the second array and print 'A'–'Z' before hitting the null at the end of that string.