c++ - Why does std::istream::getline not operate on std::string? -
in c++, istream has method called getline operate on c-style character array. know there other independent getline functions operate on istream , std::string. why separate method? why not put in istream? , why istream's getline work on c-style strings instead of std::string?
i think strings library , streams library developed separately. think why don't have universal std::string support in streams library. although has been addressed little std::fstream::open taking strings.
one thing note std::istream::getline more secure std::getline should preferred in situations.
the problem std::getline has no checking on length of string read. means malicious code (or corrupt data source) can blow memory presenting data containing long line.
with std::istream::getline have limit on how can read.
Comments
Post a Comment