Is there a one-liner to read the contents of a (not very big) text file into a string?
The shortest I've found:
#include <string>
#include <fstream>
#include <streambuf>
std::ifstream t("file.txt");
std::string str((std::istreambuf_iterator<char>(t)),
std::istreambuf_iterator<char>());
(For large files note that it is extremely inefficient solution since it has to reallocate the buffer after each new character it reads from the stream.)
credit: @Tyler McHenry Read whole ASCII file into C++ std::string