std::cout << (void*) &charArray[0];
There is an overload operator<<for here char*that tries to print a zero-terminated string that, in its opinion, the pointer points to the first character. But not all char arrays are nul-terminated strings, so garbage.
source
share