求一个read函数读取整个文本文件的例子,谢谢
网上找了半天也没找到一个可以编译通过的
read读取整个文本文件,大约80M
并保存到字符串数组,谢谢a
[解决办法]
不难吧,试试这个,刚刚手敲的
#include <string>
#include <fstream>
#include <iostream>
using namespace std;
void main()
{
string str = "";
char tmp,filename[30];
cout<<"Please input file's name: ";
cin>>filename;
ifstream ifile(filename);
if (ifile.good())
{
while (ifile.get(tmp))
{
str += tmp;
}
//cout<<str<<endl;
}
ifile.close();
}