How do I read a file into a std::string, i.e., read the whole file at once?
std::string
Text or binary mode should be specified by the caller. The solution should b
You can use the 'std::getline' function, and specify 'eof' as the delimiter. The resulting code is a little bit obscure though:
std::string data; std::ifstream in( "test.txt" ); std::getline( in, data, std::string::traits_type::to_char_type( std::string::traits_type::eof() ) );