fputs
output a line to a stream
You're viewing an older version of this page (#3460). View the current version.
INTERFACE
#include <stdio.h> int fputs ( const char *str, FILE *stream ) int puts ( const char *str )
DESCRIPTION
The function fputs writes the string pointed to by str to the stream pointed to by stream.
The function puts writes the string str, and a terminating newline character to the stream <span class="Dv">stdout</span>.
Example 1
#include <stdio.h>
int main()
{
// open text file for writing
FILE *f = fopen("fred.txt", "wt");
if (f)
{
fputs("something", f);
fclose(f);
}
return 0;
}RETURN VALUES
The fputs function returns 0 on success and <span class="Dv">EOF</span> on error; puts returns a nonnegative integer on success and <span class="Dv">EOF</span> on error.
ERRORS
<table cellspacing="0" class="refpage" style="margin-left:25px"> <tr> <td valign="top" nowrap> [<span class="Bq"><span class="Er">EBADF</span></span>] </td> <td valign="top"> The \c stream argument is not a writable stream. </td> </tr> </table> \n \n The functions fputs and puts may also fail and set <span class="Va">errno</span> for any of the errors specified for the write routine.
SEE ALSO
STANDARDS
While not mentioned in the standard, both fputs and puts print '<span class="Qlq">(null)</span>' if str is <span class="Dv">NULL</span>.