How do I read a file into a std::string, i.e., read the whole file at once?
Text or binary mode should be specified by the caller. The solution should b
Use
#include
#include
#include
int main()
{
std::ifstream input("file.txt");
std::stringstream sstr;
while(input >> sstr.rdbuf());
std::cout << sstr.str() << std::endl;
}
or something very close. I don't have a stdlib reference open to double-check myself.
Yes, I understand I didn't write the slurp function as asked.