My code like this:
std::istringstream file("res/date.json");
std::ostringstream tmp;
tmp<<file.rdbuf();
std::string s = tmp.str();
std::cout<<s<<std::endl;
The output is res/date.json
, while what I really want is the whole content of this json file.
This
std::istringstream file("res/date.json");
creates a stream (named file
) that reads from the string "res/date.json"
.
This
std::ifstream file("res/date.json");
creates a stream (named file
) that reads from the file named res/date.json
.
See the difference?