If you are trying to copy the entire file to a string stream, then this:
oss << ifs;
wrong. All that does is print the ifs address. What you want to do is:
oss << ifs.rdbuf();
And then, of course, to copy this into a string, as others say:
str = oss.str();
If you just want to get one line, then skip the string and just use getline:
std::getline(ifs,str);
source
share