Printf sets errno to 25?
Doug Gwyn <gwyn>
gwyn at brl-tgr.ARPA
Sat Dec 21 08:39:04 AEST 1985
> 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.
More information about the Comp.unix.wizards
mailing list