如题

解决方案 »

  1.   

    不知道文件长度的情况 怎么seek啊!
      

  2.   

    fstream继承自iostream,iostream的basic_istream Members中有seekg方法,msdn说:Moves the read position in a streamExample
    // basic_istream_seekg.cpp
    // compile with: /EHsc
    #include <iostream>
    #include <fstream>int main ( ) 
    {
       using namespace std;
       ifstream file;
       char c, c1;   file.open( "basic_istream_seekg.txt" );
       file.seekg(2);   // chars to skip
       file >> c;
       cout << c << endl;   file.seekg( 0, ios_base::beg );
       file >> c;
       cout << c << endl;   file.seekg( -1, ios_base::end );
       file >> c1;
       cout << c1 << endl;
    }