Pointers Concept Clarification

Hi everyone!
I am a little confused while comparing char pointers to integer pointers.
Here is the problem:
consider the following statement;
char *ptr = "Hello";
char cArr[] = "Hello";
when I do cout << ptr; it prints Hello, same is the case with the statement
cout << cArr;
as ptr and cArr are pointers, they should print addresses rather than contents, but if I have an interger array i.e.
int iArr[] = {1, 2, 3};
if I cout << iArr; it displays the expected result(i.e. prints address) but pointers to character array while outputting doesn't show the address but shows the contents, Why??
Please address the issue.
Thanks in advance

Regards,
Ali
The << operator is overloaded to, when printing a char*, actually acquire the string at that location and print it instead of the address. To get the address you can cast it to another pointer type.
The first statement you posted is incorrect. You must have a const char*, not simply a char*.

As for your question, that is because character arrays are treated differently, so instead of printing the address it prints the "string" of characters.
Topic archived. No new replies allowed.