Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site brl-tgr.ARPA Path: utzoo!watmath!clyde!cbosgd!gatech!seismo!brl-tgr!gwyn From: gwyn@brl-tgr.ARPA (Doug Gwyn ) Newsgroups: net.unix-wizards Subject: Re: Printf sets errno to 25? Message-ID: <952@brl-tgr.ARPA> Date: Fri, 20-Dec-85 17:39:04 EST Article-I.D.: brl-tgr.952 Posted: Fri Dec 20 17:39:04 1985 Date-Received: Sat, 21-Dec-85 14:42:46 EST References: <119@cpsc6a.UUCP> <212@iclbra.UUCP> Distribution: net Organization: Ballistic Research Lab Lines: 13 > The problem is a common misunderstanding about the use of errno. The value > in errno is useful if, and only if, the call has returned a value indicating > failure. This value is commonly -1, and sometimes NULL for functions > returning pointers. The Intro(2) manual page says: "Errno is not cleared on > successful calls, so it should be tested only after an error has been indicated" > > The documentation I have for printf further states that it, fprintf and sprintf > return the number of characters transmitted, or a negative value if an output > error was encountered. Close, but not quite. `errno' is only set by unsuccessful SYSTEM CALLS (and some math library routines, alas). Therefore, failure of printf() does not imply that errno will correctly indicate the reason for failure.