cstdiofile file
while(file.readstring(buff,128))
{
......
}
我读到file的最后了,下次怎么重新开始从头读,不想再OPEN一次了,谢谢

解决方案 »

  1.   

    CStdioFile::Seek virtual ULONGLONG Seek(
       LONGLONG lOff,
       UINT nFrom 
    );Parameters
    lOff
    Number of bytes to move the pointer. nFrom
    Pointer movement mode. Must be one of the following values: CFile::begin: Move the file pointer lOff bytes forward from the beginning of the file. CFile::current: Move the file pointer lOff bytes from the current position in the file. CFile::end: Move the file pointer lOff bytes from the end of the file. Note that lOff must be negative to seek into the existing file; positive values will seek past the end of the file. 
      

  2.   


    CStdioFile cfile(_T("Stdio_Seek_File.dat"), CFile::modeWrite |
       CFile::modeCreate);
    LONGLONG lOff = 1000;
    ULONGLONG lActual = cfile.Seek(lOff, CFile::begin);
      

  3.   

    cstdiofile也是继承cfile类
    用seek来指向头
    cstdiofile file;
    file.Seek(0,CFile::begin);