This section describes functions for performing character- and line-oriented output.
These functions are declared in the header file `stdio.h'.
fputc
function converts the character c to type unsigned char
, and writes it to the stream stream. EOF
is returned if a write error occurs; otherwise the character c is returned.
fputc
, except that most systems implement it as a macro, making it faster. One consequence is that it may evaluate the stream argument more than once. putc
is usually the best function to use for writing a single character.
putchar
function is equivalent to putc
with stdout
as the value of the stream argument.
fputs
writes the string s to the stream stream. The terminating null character is not written. This function does not add a newline character, either. It outputs only the chars in the string.
This function returns EOF
if a write error occurs, and otherwise a non-negative value.
For example:
fputs ("Are ", stdout); fputs ("you ", stdout); fputs ("hungry?\n", stdout);
outputs the text `Are you hungry?' followed by a newline.
puts
function writes the string s to the stream stdout
followed by a newline. The terminating null character of the string is not written.
puts
is the most convenient function for printing simple messages. For example:
puts ("This is a message.");
int
) to stream. It is provided for compatibility with SVID, but we recommend you use fwrite
instead (see Block Input/Output).