If C++ had been all been invented in one fell swoop, it probably wouldn't exist at all -- if you wanted to read a string, you'd have to read it into a std::string
, and that would be the end of it.
Unfortunately, C++ was used for quite a while before std::string
was standardized (or invented at all). Both operator>>
and istream::getline
(not to be mistaken for std::getline
) were invented during that time. When they were invented, there was little (or no) real alternative, so they worked with arrays of char.
Today, of course, there are alternatives, and it's best to just avoid these unless you get stuck writing code with some ancient compiler that doesn't support the superior alternatives.