Arrays: int vs char

Hi everybody,

I know that the identifier for a number type array (int,float,...) is the pointer pointing the considered array. For instance

1
2
  int A[3]={1,2,3};
  cout<<A;


displays the address of the first array element. But for a char array

1
2
  char S[4]={'a','b','c','\0'};
  cout<<S;


S will display the entire character string while &S will display the address. Is S also a pointer in the same manner than A? If yes why it doesn't deliver the address? Looks like a char array behaves like a single value variable.

Thanks for your help!
S and A are arrays not pointers.
In standard class std::basic_string operator << is overloaded in a special way that to output strings.
Last edited on
There are many overloads for operator<< and char [] indeed resolves to a different one than int [].
Thanks to both of you. That is a very important detail that is kept well hidden. I can now quit the "trial and error" method when using char.
Topic archived. No new replies allowed.