[comp.lang.c] what does fputs return?

davek@bcs800.UUCP (Dave Kennedy) (11/21/90)

I ran into an odd little bug porting the following line of code:

    while (fgets(string, SIZE, file1) && fputs(string, file2));

Please note the word PORTING; I didn't write it.  

Anyway, while tracking the bug in this line, I found that the
various documentation I have for fputs is rather conflicting.
Following is what I found:

Document                             fputs return value upon success
-------------------------------      -------------------------------
AT&T Sys V Rel 2.0/3.0 Prog Ref      Doesn't say - just an int
Digital VAX C RTL Ref Manual         Nonnegative number
SVID Issue 2, Volume I               Number of characters written
Turbo C Ref Guide Version 2.0        The last character written
Turbo C++ Library Ref                The last character written
K&R II, pp. 164-165                  0
AIX O/S Technical Ref                Number of characters written
SCO Xenix System V Prog Ref          Doesn't say - just an int

All return EOF if there is an error.

I could go on, but I'm sure you get the idea.  Unfortunately, I don't
have access to the ANSI standard document, so what is the "right"
return value upon success?  If the return value is undefined, then all
of the above are correct.
are correct.
-- 
Dave Kennedy  |  ...!uunet!gatech!emory!bcs800!davek  |  If you don't like  |
404-431-1254  |  Any opinions expressed are all mine  |  it, don't read it  |

henry@zoo.toronto.edu (Henry Spencer) (11/22/90)

In article <1123@bcs800.UUCP> davek@bcs800.UUCP (Dave Kennedy) writes:
>...don't have access to the ANSI standard document, so what is the "right"
>return value upon success?

A non-negative value.
-- 
"I don't *want* to be normal!"         | Henry Spencer at U of Toronto Zoology
"Not to worry."                        |  henry@zoo.toronto.edu   utzoo!henry