linux c 语言之--fseek(),fseeko(),fseeko64()讲解 (转载)

转载:http://blog.csdn.net/lemoncyb/article/details/16841317函数


fseek() 函数讲解:
函数定义: .net

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

 

int fseeko(FILE *stream, off_t offset, int fromwhere);blog

 

int fseeko64(FILE *stream, off64_t offset, int fromwhere);it


参数: io

stream:文件指针stream

 

fromwhere:偏移起始位置file

 

offset:偏移量数据类型


功能: error

函数设置文件指针stream的位置。若是执行成功,stream将指向以fromwhere(偏移起始位置:文件头0(SEEK_SET),当前位置1(SEEK_CUR),文件尾2(SEEK_END))为基准,偏移offset(指针偏移量)个字节的位置。若是执行失败(好比offset超过文件自身大小),则不改变stream指向的位置。

 

说明:这几个函数惟一的不一样是offset的数据类型不一样,相应的可以处理的偏移量的范围也就有大有小。


返回值:

成功,返回0,失败返回-1,并设置errno的值,能够用perror()函数输出错误。 fseek position the file(文件) position(位置) pointer(指针) for the file referenced by stream to the byte location calculated by offset.

相关文章
相关标签/搜索