|> > Because EOF is a valid integer, ferror(3S) should be
|> > used to detect getw errors. ^^^^^^
|> ^^^^
|>
|> Since the quoted section talks about getw and getw only, it has no
|> relevance for getchar, getc, and fgetc. For the these functions,
|> an EOF return value _always_ has one meaning and one meaning only:
|> that the read tried to go past the end of the file.
|>
|> getw is a non-standard function that has very little use.
|>
|> > WARNING <<<<<<<<<<<<<<<<<<<<<<
|> > If the integer value returned by getc, getchar, or fgetc is
|> > stored into a character variable, then compared against the
|> > ^^^^^^^^^^^^^^^^^^
|> > integer constant EOF, the comparison may never succeed
|> > because sign-extension of a character on widening to integer
|> > is machine-dependent.
|>
|> This section explains why one must not ever store the return value
|> of getchar, getc, or fgetc in a variable that has a smaller type than
|> int. You can find the same information in this newsgroups FAQ.
|>
|> --
|> My name is Ozymandias, king of kings/Look on my works, ye Mighty, and despair!
This is probably the most cumbersome aspect of the C language.
Functions that return a value that is real data or a "fault"
condition, such as end-of-file. In the old'n days, it was a big
overhead to put a variable on the stack, with today's processors
it really ain't that big a deal.
It would make sense to redefine routines such as getc as:
boolean = getc(&input_char)
if boolean == FALSE, then no character was read, if TRUE
then a character was placed in input_char.
but, before I'm flamed, unmercifully, I love C and don't
advocate changing it(too much) :-)
--
-----------------------------------------------------------------
The philosophy of the classroom will be the philosophy of the
government in the next generation.
-- Abraham Lincoln
Public opinion is a weak tyrant compared with our own
private opinion.
-- Thoreau
-----------------------------------------------------------------