fstream的问题
fstream file_stream;
char* filename=new char[256];
char* filebuf=new char[1025];
::memset(filebuf,0,1025);
::memset(filename,0,256);
memcpy(filename,"e:\\test.txt",256);
file_stream.open(filename,ios::binary,filebuf::sh_read);
if(file_stream.fail())
{
AfxMessageBox("读取失败!");
}
file_stream.getline(filebuf,1024, '\n ');
file_stream.close();
delete filename;
delete filebuf;
提示读取失败,不知道这个类怎么用法?
[解决办法]
ios::binary | ios::in | ios::out,
[解决办法]
将第一行的“fstream file_stream; ”去掉,将第七行的“file_stream.open(filename,ios::binary,filebuf::sh_read); ”改为“fstream file_stream(filename,ios_base::in | ios_base::out | ios_base::trunc);
”你试试看好不好使