一次读取文件全部内容
#include <iostream>
#include <sstream>
#include <fstream>
using namespace std;
int main() {
ifstream in;
in.open("test.txt");
if(!in.is_open()) {
cout << "File can not opened" << endl;
}
// 一次读取文件全部内容
stringstream buffer;
buffer << in.rdbuf();
string content = string(buffer.str());
cout << content << endl;
}