CStdioFile f;
f.open("tt.txt",CFile::modeRead|CFile::modeWrite);
此时,用readstring()不能读,说“访问tt.txt发生错误!”
真是奇怪,光用modeRead而不带modeWrite时,一切正常!
是什么原因?
f.open("tt.txt",CFile::modeRead|CFile::modeWrite);
此时,用readstring()不能读,说“访问tt.txt发生错误!”
真是奇怪,光用modeRead而不带modeWrite时,一切正常!
是什么原因?
即打开一个文件,只能读取。
CFile::modeWrite在msdn中的解释如下:Opens the file for writing only.
即打开一个文件,只能写入。
如果你想既读又写,那么应该用:CFile::modeReadWrite
Opens the file for reading and writing.