I was wanting to know if there was a simple way to set a std::string
equal to the contents of a file in C++. So far, I was thinking something like this: (although I haven't tested it, so I don't know if it will work)
#include <fstream>
#include <string>
int main(int argc, char *argv[]){
fstream in("file.txt");
string str;
str = in;
return 0;
}
Is this a way to accomplish this? If not, is there a simple way to do so? Thanks!