C++ 学习 - 一次性读取文件全部内容

#include <iostream>
#include <string>
#include <sstream>
#include <fstream>
using namespace std;

int main()
{
    string str;

    ifstream fin;
    fin.open("conf.txt", ios::in);
    stringstream buf;
    buf << fin.rdbuf(); 
    str = buf.str();

    cout << str << endl;

    fin.close();
    system("pause");
    return 0;
}

猜你喜欢

转载自blog.csdn.net/guo_lei_lamant/article/details/80678661