fseek(inFp,0,2); 
fileSize = ftell(inFp); //取得文件的大小 
fseek(inFp,0,0); 
请问这段代码是如何解释的呢?请教各位高手。

解决方案 »

  1.   

    fseek
    Moves the file pointer to a specified location.
    int fseek( FILE *stream, long offset, int origin );
    The argument origin must be one of the following constants, defined in STDIO.H:
    SEEK_CUR  Current position of file pointer
    SEEK_END  End of file
    SEEK_SET  Beginning of file
    stdio.h
    #define SEEK_CUR    1
    #define SEEK_END    2
    #define SEEK_SET    0ftell
    Gets the current position of a file pointer.fseek(inFp,0,2); //移动指针到文件尾部
    fileSize = ftell(inFp); //获取当前文件指针位置 因为前面已经移到文件尾部,所以当前指针位置时文件长度
    fseek(inFp,0,0); //重新移动文件指针至文件开始 为后面的都写准备MSDN是好帮手,有问F1
      

  2.   

            fseek(inFp,0,2); //尾端,2就是SEEK_END
    fileSize = ftell(inFp); //取得文件的大小 
    fseek(inFp,0,0); //0就是SEEK_SET,就是绝对定位。