operator<<overloading char*expects a pointer to the zero end of the character array, so that it knows where the line ends. It so happened that your variables charwere allocated contiguously in memory and that after them 0 bytes followed. However, the code causes undefined behavior.
To print a single char, look for a pointer:
cout << *myMap['a'] << endl;
source
share