Go to the previous, next section.
This section describes functions for performing character- and line-oriented output.
These functions are declared in the header file `stdio.h'.
Function: int fputc (int c, FILE *stream)
The 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.
Function: int putc (int c, FILE *stream)
This is just like 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.
The putchar function is equivalent to putc with
stdout as the value of the stream argument.
Function: int fputs (const char *s, FILE *stream)
The function 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.
Function: int puts (const char *s)
The 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.");
Function: int putw (int w, FILE *stream)
This function writes the word w (that is, an int) to
stream. It is provided for compatibility with SVID, but we
recommend you use fwrite instead (see section Block Input/Output).
Go to the previous, next section.