When you supply a pointer it will use the std::ostream& operator<<( const void* value );
overload and output the address pointed at by value
.
The difference is that std::ostream& operator<<(std::ostream& os, const char* s)
is a special case and it will dereference s
and output the char
s until a \0
is encountered. As long as no \0
is encountered, it’ll step s
forward.
CLICK HERE to find out more related problems solutions.