fgets

Blair P. Houghton bhoughto at cmdnfs.intel.com
Wed Oct 24 02:07:03 AEST 1990


In article <52039 at unix.cis.pitt.edu> ydist at unix.cis.pitt.edu (Yijun Ding) writes:
>After many tries to recompile my word processor by TC++, I find
>the following difference:
>
>fputs("", fp) return 0 in TC 2.0
>              return (-1) in TC++
>
>Which is correct ?

Under ANSI, the return value on error from fputs() is an EOF, the
return value if no error is "nonnegative".

In older versions (e.g.: on Apollos; and on Ultrix boxes,
which prove that "older" is not necessarily noncontemporaneous
with "current" :) there doesn't seem to be any mention of
fputs(3)'s having a return value.  It seems logical that
fputs() might have returned 0 on failure and nonzero on
success, such that `if ( fputs(...) )' might work.

In your case, the WP seems to depend on the "older" return
value.  Go through and see if you can find where they've
assigned or compared the return value of fputs() with anything.

try

	egrep '=.*fputs|fputs.*=' *.[ch]

in the source directory.

				--Blair
				  "...somma that old-time
				   a-rock and roll..."
				   -some Seeger



More information about the Comp.lang.c mailing list