























//打开文件(modeCreate:文件不存在就创建文件,若存在而无modeNoTruncate标志则清空文件)
CFile file("text.txt",CFile::modeReadWrite|CFile::modeNoTruncate|CFile::modeCreate);
char pbuf[100];
UINT nBytesRead=file.Read(pbuf,100);
//AfxMessageBox(pbuf);
strcpy(pbuf,"this file is modified by yjm");
//写入文件(从当前位置)
file.Write(pbuf,sizeof(pbuf));
//AfxMessageBox(pbuf);
file.Close();
virtual LONG Seek(LONG lOff,UINT nFrom);
作用:把文件位置指针相对移动一个偏移量;
参数:
nForm:标志移动的基准,可以取CFile::begin / CFile::current / CFile::end,分别表示相对于文件头、当前位置、文件尾;
IOff:偏移量(可正可负)
LONG IOffset
=1000,IActual;此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。