I have an array of chars like this one:
char arr[3]=\"hi\";
cout << arr;// this will print out hi
So is the operator<< has an
Please see here for details on cout
: Standard output stream. Whilst in this page, please click and see the link that says "ostream::operator<<"
Likewise see here for details on cin
: Standard input stream. Whilst here, please click and see the link that says "operator (>>)"
Exactly in the same way as cout
works.
The array arr
decays into pointer type, and there exists an overloaded version of istream
as well which takes char*
as argument. So arr
gets passed to the operator>>
as char*
after decaying.
Your ostream
and istream
do have operator<<
and operator>>
overloaded to take a char*
, and arrays decay into pointers to the first element. So, yes it does what you say it does.