为什么C文件流的开头称为“ SEEK_SET”?

阿霍塔

有三个origin常量,你可以像使用功能fseek,从您的判断offset数:SEEK_SETSEEK_CUR,和SEEK_ENDSEEK_CUR并且SEEK_END似乎不言自明地表示文件流的当前位置和结尾,但是为什么SEEK_SET用来表示开头?为什么不这样SEEK_BEG呢?

因为可以添加偏移量。通过使用SEEK_SET,您可以显式设置偏移量。(通过将其添加到开头)

从fseek的联机帮助页中:

The new position, measured in bytes, is
obtained by adding offset bytes to the position specified by whence.
If whence is set to SEEK_SET, SEEK_CUR, or SEEK_END, the offset is
relative to the start of the file, the current position indicator, or
end-of-file, respectively.

从lseek的联机帮助页中:

   SEEK_SET
          The file offset is set to offset bytes.

   SEEK_CUR
          The file offset is set to its current location plus offset
          bytes.

   SEEK_END
          The file offset is set to the size of the file plus offset
          bytes.

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章