std::istringstream file("res/date.json"); std::ostringstream tmp; tmp<<file.rdbuf(); std::string s = tmp.str(); std::cout<<s<<std::endl;
输出是res / date.json,而我真正想要的是这个json文件的全部内容.
std::istringstream file("res/date.json");
创建一个从字符串“res / date.json”读取的流(命名文件).
这个
std::ifstream file("res/date.json");
创建一个从名为res / date.json的文件中读取的流(命名文件).
看到不同?