I'm confused by this statement, from C Programming: A Modern Approach, 2nd Edition on Page 446,
For binary streams,
fseek
isn't required to support calls in which whence isSEEK_END
Why is that? That seems like weird stipulation.
I'm confused by this statement, from C Programming: A Modern Approach, 2nd Edition on Page 446,
For binary streams,
fseek
isn't required to support calls in which whence isSEEK_END
Why is that? That seems like weird stipulation.
Looking it up in the spec, it says
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 trailingnull
characters) or for any stream with state-dependent encoding that does not assuredly end in the initial shift state.
So I guess it's the presence of null characters that lead to this behavior, though I'm not sure why they're treated differently here.