Printing an array of chars.

Consider the following code:

char c[]="hello";
cout << c;

I know that the name of an array of chars is a pointer. So, why does "cout" print the content of the array instead of the address of it?


operator<<() has an overload that takes an output stream (e.g. std::cout) and a character pointer (e.g. "a string literal") as operands and sends to the stream the string pointed to by the pointer, rather than sending a textual representation of the pointer value.
Last edited on
Topic archived. No new replies allowed.