ftell与fseek

fseek原型:  int fseek(FILE *stream,long int offset,int whence);

成功返回0,出错返回非0

whence有三个值可以选择:

SEEK_SET:文件开头

SEEK_CUR:当前位置

SEEK_END:文件结尾

fseek(fp,0,SEEK_END) 将文件指针移动到文件结尾,然后再调用ftell可以求得文件的长度。

ftell原型:long int ftell(FILE *stream);

成功返回文件指针当前位置到文件开头的长度。

猜你喜欢

转载自blog.csdn.net/aabb7012086/article/details/82355906