This section describes functions for performing character- and line-oriented output.
These functions are declared in the header file `stdio.h'.
fputcfunction converts the character c to type
unsigned char, and writes it to the stream stream.
EOFis 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, which is an exception to the general rule for macros.
putcis usually the best function to use for writing a single character.
putcharfunction is equivalent to
stdoutas the value of the stream argument.
fputswrites 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 characters in the string.
This function returns
EOF if a write error occurs, and otherwise
a non-negative value.
fputs ("Are ", stdout); fputs ("you ", stdout); fputs ("hungry?\n", stdout);
outputs the text `Are you hungry?' followed by a newline.
putsfunction writes the string s to the stream
stdoutfollowed by a newline. The terminating null character of the string is not written. (Note that
fputsdoes not write a newline as this function does.)
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
fwriteinstead (see section Block Input/Output).
Go to the first, previous, next, last section, table of contents.