A simple way to read a whole file into a std::string.
1 2 3 4 5 6 7 | #include <fstream> #include <sstream> ... std::ifstream file( "a.txt" ); std::stringstream buffer; buffer << file.rdbuf(); std::string content = buffer.str(); |
A blog about coding
A simple way to read a whole file into a std::string.
1 2 3 4 5 6 7 | #include <fstream> #include <sstream> ... std::ifstream file( "a.txt" ); std::stringstream buffer; buffer << file.rdbuf(); std::string content = buffer.str(); |