[TUHS] ratfor vibe

Adam Thornton athornton at gmail.com
Sat Feb 5 03:35:38 AEST 2022


On Thu, Feb 3, 2022 at 11:07 PM Ori Idan <ori at heliconbooks.com> wrote:

> As for EOF it is 0xFF which is not always -1, depending if your char is
> signed or unsigned.
>
>
Ha!  You fell into my trap!  getc() returns an int!  (I don't know if EOF
is _always_ "all bits set", and even if it is, that's only -1 on a
twos-complement machine, if we want to head off into some real pedantry...)

The need to use feof() and ferror() at least appear in the BUGS section on
my Mac.  Linux is not so gracious.  The real bug, if you ask me, which no
one did, is that getc() and pals return an int rather than a char, which is
surprising and certainly has tripped me up several times across the decades
(and yes, I understand that since any character value is a legal character
to have gotten, you need some other way of signalling an error).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://minnie.tuhs.org/pipermail/tuhs/attachments/20220204/631bd0f6/attachment.htm>


More information about the TUHS mailing list