gpt4 book ai didi

c - 二进制流上带有 WHENCE 的 SEEK_END

转载 作者:行者123 更新时间:2023-11-30 20:19:02 28 4
gpt4 key购买 nike

我对 C Programming: A Modern Approach, 2nd Edition 的这个说法感到困惑第 446 页,

For binary streams, fseek isn't required to support calls in which whence is SEEK_END

这是为什么呢?这似乎是一个奇怪的规定。

最佳答案

查找in the spec ,它说

Setting the file position indicator to end-of-file, as with fseek(file, 0, SEEK_END), has undefined behavior for a binary stream (because of possible trailing null characters) or for any stream with state-dependent encoding that does not assuredly end in the initial shift state.

所以我猜是空字符的存在导致了这种行为,尽管我不确定为什么它们在这里受到不同的对待。

关于c - 二进制流上带有 WHENCE 的 SEEK_END,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52105263/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com