I\'d like to read whole content of a text file to a std::string object with c++.
std::string
With Python, I can write:
text = open(\"text.txt\", \"
There's another thread on this subject.
My solutions from this thread (both one-liners):
The nice (see Milan's second solution):
string str((istreambuf_iterator(ifs)), istreambuf_iterator());
and the fast:
string str(static_cast(stringstream() << ifs.rdbuf()).str());