This:
const char * terry = \"hello\";
cout<
prints hello
instead of the memory address of the \'h\'
.
std::cout
is defined as std::ostream
with this definition of operator<<
.
Notably this line:
template< class CharT, class Traits >
basic_ostream& operator<<( basic_ostream& os,
const char* s );
This gets selected when you use <<
with an argument of type char*
.
The case of any other non-char pointer type goes here:
basic_ostream& operator<<( const void* value );
This continues to std::num_put which is made for formatting numeric values. Therefore, the pointer is interepreted numerically like %p
in C formatting functions.