我用open语句打开一个文本文件,在到达文件尾时如何将指针移到开头

解决方案 »

  1.   

    CFile aaa;
    aaa.SeekToBegin();
      

  2.   

    extern CFile cfile;
    LONG lOffset = 1000, lActual;
    lActual = cfile.Seek( lOffset, CFile::begin );
      

  3.   

    CFile MyFile;
    MyFile.Seek( long loff,CFile::begin )from msdn:
    ParameterslOffNumber of bytes to move the pointer.nFromPointer 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. 
    你可以把第一个参数设置为0或1,随便你怎么都可以,看参数设置吧