通过man 2 lseek可以查看linux中的系统函数lseek函数的帮助文档,为了更好的学习,我把这些重要内容翻译过来

 NAME
lseek - reposition read/write file offset//重置读或写文件的偏移量 SYNOPSIS//摘要
#include <sys/types.h>//如果要使用lseek函数,需要包含这两个头文件
#include <unistd.h> off_t lseek(int fd, off_t offset, int whence);//lseek的声明格式 DESCRIPTION//描述
The lseek() function repositions the offset of the open file associated with the file descriptor fd to the argument offset according to the directive whence as follows:
//lseek()函数的作用是,重置和文件描述符fd关联的打开的文件的偏移量,把这个偏移量重置为参数offset,在重置时要根据指令whence来做。whence的可包含的指令如下:
SEEK_SET
The offset is set to offset bytes.//如果whence的指令是SEEK_SET,则文件偏移量设定为参数offset大小的字节 SEEK_CUR
The offset is set to its current location plus offset bytes.//如果whence的指令是SEEK_CUR,则文件偏移量设定为当前位置加上offset大小的字节 SEEK_END
The offset is set to the size of the file plus offset bytes.//如果whence的指令是SEEK_END,则文件偏移量设定为文件大小再加上offset大小的字节 The lseek() function allows the file offset to be set beyond the end of the file (but this does not change the
size of the file). If data is later written at this point, subsequent reads of the data in the gap (a "hole")
return null bytes ('\0') until data is actually written into the gap.//lseek()函数允许把文件的偏移量设置的值超过文件的结束(虽然把偏移量设定的值超过了文件的结尾,但是并不会改变文件大小)。如果数据后来被写入到这个偏移量位置,在把数据真正写入这个从文件末尾到偏移量之间的空间,那么随后在读取从文件末尾到设置的偏移量的位置,返回的都是‘\0’,
RETURN VALUE
Upon successful completion, lseek() returns the resulting offset location as measured in bytes from the begin‐
ning of the file. On error, the value (off_t) - is returned and errno is set to indicate the error.//当lseek成功完成,lseek()返回的偏移量是距离文件开头的偏移量,大小以自己为单位衡量。如果错误,返回值为-1,并设置errno的值

最新文章

  1. c/c++ 缓冲区的刷新
  2. 从倒影说起,谈谈 CSS 继承 inherit(转)
  3. Git初级实践教程(图文)
  4. 联想Phab2 Pro Tango手机测评
  5. hdu-5496 Beauty of Sequence(递推)
  6. Javascript 笔记与总结(2-9)获取运行时的 style 对象
  7. 基于LR的HTTP协议接口性能测试脚本实例
  8. IOS之以UIBezierPath绘制饼状图
  9. [Testing] 測試理論電子文件
  10. 从零开始学习UNITY3D(GUI篇 群组视图控件)
  11. 干货分享:MySQL之化险为夷的【钻石】抢购风暴【转载】
  12. Linux常见命令(三)
  13. javascript入门知识点总结(一)
  14. Lucene 4.4.0中常用的几个分词器
  15. [GoogleBlog]new-approach-to-china
  16. DOM对象与jquery对象相互转换
  17. Linux系统学习之软件安装
  18. 微软BI 之SSIS 系列 - 在 SSIS 输出平面文件时根据运行日期生成不同的文件名称
  19. $.ajax()参数详解及标准写法(转)
  20. 使用 Node.js 搭建微服务网关

热门文章

  1. Linux常用命令1
  2. android subclipse subversive
  3. chrome浏览器调用 ajax 提示net::ERR_INCOMPLETE_CHUNKED_ENCODING问题解决方案,以及 Response.Close 和 Response.End 的一些问题。
  4. 使用HTML5新支持的搭建WebRtc环境来作为视频通讯
  5. U-Mail反垃圾邮件网关过滤Locky勒索邮件
  6. android_demo之生成颜色布局
  7. 转载:Solr的自动完成实现方式(第二部分:Suggester方式)
  8. Android Studio使用百度地图示例BaiduMapsApiASDemo
  9. C# lambda
  10. 如何解救在异步Java代码中已检测的异常