您的位置:首页 > 其它

一次读取文件中所有内容

2010-07-08 20:16 295 查看

http://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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: