“cout” and “char address” [duplicate]

I believe the << operator recognizes it as a string. Casting it to a void* should work:

cout << (void*)&p;

std::basic_ostream has a specialized operator that takes a std::basic_streambuf (which basically is a string (in this case)):

_Myt& operator<<(_Mysb *_Strbuf)

as opposed to the operator that takes any pointer (except char* of course):

_Myt& operator<<(const void *_Val)

Leave a Comment