有三个origin
常量,你可以像使用功能fseek
,从您的判断offset
数:SEEK_SET
,SEEK_CUR
,和SEEK_END
。SEEK_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] 删除。
我来说两句