Difference between char arrays and other arrays

Hello,

How does initializing a char to a string literal work? For example, lets say I have this code.

1
2
char mychar[] = "Hi";
cout << mychar << "\n"; // prints "Hi", not address 


Printing mychar to the output prints its data, not the address. I believe this is because mychar is an array, not a pointer. Does this mean that mychar is in array form and not pointer form, so it returns the string it holds?

However, lets say I have an int array as following:

1
2
int myarray[1] = {5};
cout << myarray << "\n"; // prints an address 


This prints the address of the array. In essence, is this difference something special for char arrays, or is it the same for int arrays, just it is more "hidden"?

P.S. If you were reading my last discussion, it was getting a little off topic, so I decided to make this.
The << operator here has been programmed such that if you pass it a char pointer, it will dereference it (and output what it points to as far as the next zero value), whereas for other kinds of pointers, it does not.
Ahh, I see. Thank you very much!
Topic archived. No new replies allowed.