RSoIsCaIrLiIoA said:
am i for you the kind of person that has need of something else than
K&R book? then "Question 20.4" is not in the faq posted here in this
news-group
According to groups.google.com, the full FAQ list has not been posted
to comp.lang.c since Nov 1, 2004. An abridged FAQ list was posted on
Nov 1, 2005 and again on Feb 1, 2006; the abridged list doesn't
include question 20.4. The most recently posted full version doesn't
include question 20.4 either.
I've tended to ignore the posted FAQ, since the web version is so much
easier (for me) to access; perhaps that's why Steve hasn't been
posting it as regularly. It was also updated recently, and question
20.4 was part of the update.
Here's question 20.4 from the current web version:
Q: What's the right way to use errno?
A: In general, you should detect errors by checking return values,
and use errno only to distinguish among the various causes of an
error, such as ``File not found'' or ``Permission
denied''. (Typically, you use perror or strerror to print these
discriminating error messages.) It's only necessary to detect
errors with errno when a function does not have a unique,
unambiguous, out-of-band error return (i.e. because all of its
possible return values are valid; one example is atoi). In these
cases (and in these cases only; check the documentation to be sure
whether a function allows this), you can detect errors by setting
errno to 0, calling the function, then testing errno. (Setting
errno to 0 first is important, as no library function ever does
that for you.)
To make error messages useful, they should include all relevant
information. Besides the strerror text derived from errno, it may
also be appropriate to print the name of the program, the
operation which failed (preferably in terms which will be
meaningful to the user), the name of the file for which the
operation failed, and, if some input file (script or source file)
is being read, the name and current line number of that file.
See also question 12.24.
References: ISO Sec. 7.1.4, Sec. 7.9.10.4, Sec. 7.11.6.2
CT&P Sec. 5.4 p. 73
PCS Sec. 11 p. 168, Sec. 14 p. 254
My offer stands: if you're really unable to read the web version, I
can send you a copy. See my previous article for details. If you
have any kind of web access at all, it will be easier for you either
to access the web version directly, or to download another version
yourself from c-faq.com, but I don't know your situation.
I make this offer because I made it before, and I don't want to take
it back. However, you have recently been disrupting this newsgroup by
repeatedly posting huge chunks of assembly language, and you have
continued to do so after being asked to stop. You've engaged in
similar trollish behavior in the past. If you don't stop, this will
be my very last offer to help you. This offer expires permanently in
one week.