-2

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 is SEEK_END

Why is that? That seems like weird stipulation.

Evan Carroll
  • 78,363
  • 46
  • 261
  • 468

1 Answers1

1

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 trailing null 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.

Evan Carroll
  • 78,363
  • 46
  • 261
  • 468