C语言函数—fsetpos

函数名

fseek

功 能

重定位流上的文件指针

用 法

int fseek(FILE *stream, long offset, int fromwhere);

程序例

#include <stdio.h> 

long filesize(FILE *stream); 

int main(void) 
{ 
   FILE *stream; 

   stream = fopen("MYFILE.TXT", "w+"); 
   fprintf(stream, "This is a test"); 
   printf("Filesize of MYFILE.TXT is %ld bytesn", filesize(stream)); 
   fclose(stream); 
   return 0; 
} 

long filesize(FILE *stream) 
{ 
   long curpos, length; 

   curpos = ftell(stream); 
   fseek(stream, 0L, SEEK_END); 
   length = ftell(stream); 
   fseek(stream, curpos, SEEK_SET); 
   return length; 
} 
  
  
  
  
  

如果引用本站的原创文章,请注明原文链接:,本站保留追究责任的权利!