vC++6.0写文件时,如何让软件记住当前位置,并且以后能回到这个位置。我知道的内容是
             CFile file;
             DWORD pos;             pos=file.GetPosition();            接下来怎么做呢?是file.seek(pos);吗?

解决方案 »

  1.   

    参数错了。其实我倒觉得用fgetpos/fseekpos比较舒服:Example
    // crt_fgetpos.c
    /* This program opens a file and reads
     * bytes at several different locations.
     */#include <stdio.h>int main( void )
    {
       FILE   *stream;
       fpos_t pos;
       char   buffer[20];   if( (stream = fopen( "crt_fgetpos.txt", "rb" )) == NULL )
          printf( "Trouble opening file\n" );
       else
       {
          /* Read some data and then check the position. */
          fread( buffer, sizeof( char ), 5, stream );
          if( fgetpos( stream, &pos ) != 0 )
             perror( "fgetpos error" );
          else
          {
             fread( buffer, sizeof( char ), 10, stream );
             printf( "10 bytes at byte %I64d: %.10s\n", pos, buffer );
          }   /* Set a new position and read more data */
       pos = 14;
       if( fsetpos( stream, &pos ) != 0 )
          perror( "fsetpos error" );   fread( buffer, sizeof( char ), 10, stream );
       printf( "10 bytes at byte %I64d: %.10s\n", pos, buffer );
       fclose( stream );
       }
    }
    Input: crt_fgetpos.txt
    This is the input for crt_fgetpos.
    Output
    10 bytes at byte 5: is the inp
    10 bytes at byte 14: put for cr
      

  2.   

    DWORD dwPosition = cfile.GetPosition();
    lActual = cfile.Seek( dwPosition , CFile::begin );