876
技術社區[雲棲]
一次讀取文件中所有內容
https://blog.csdn.net/banzhiyu/archive/2007/07/26/1708438.aspx
一次讀取文件中所有內容
#include <fstream>
#include <sstream>
#include <string>
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
string str;
ifstream ifile("test.txt");
ostringstream tmp;
tmp<<ifile.rdbuf(); //
str = tmp.str();
cout<<str<<endl;
system("pause");
return 0;
}
最後更新:2017-04-02 06:51:22