This section describes functions for performing character- and line-oriented output.
These narrow streams functions are declared in the header file stdio.h and the wide stream functions in wchar.h.
Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe corrupt lock | See POSIX Safety Concepts.
The
fputcfunction converts the character c to typeunsigned char, and writes it to the stream stream.EOFis returned if a write error occurs; otherwise the character c is returned.
Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe corrupt lock | See POSIX Safety Concepts.
The
fputwcfunction writes the wide character wc to the stream stream.WEOFis returned if a write error occurs; otherwise the character wc is returned.
Preliminary: | MT-Safe race:stream | AS-Unsafe corrupt | AC-Unsafe corrupt | See POSIX Safety Concepts.
The
fputc_unlockedfunction is equivalent to thefputcfunction except that it does not implicitly lock the stream.
Preliminary: | MT-Safe race:stream | AS-Unsafe corrupt | AC-Unsafe corrupt | See POSIX Safety Concepts.
The
fputwc_unlockedfunction is equivalent to thefputwcfunction except that it does not implicitly lock the stream.This function is a GNU extension.
Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe corrupt lock | See POSIX Safety Concepts.
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, which is an exception to the general rule for macros.putcis usually the best function to use for writing a single character.
Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe corrupt lock | See POSIX Safety Concepts.
This is just like
fputwc, except that it can be implement 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.putwcis usually the best function to use for writing a single wide character.
Preliminary: | MT-Safe race:stream | AS-Unsafe corrupt | AC-Unsafe corrupt | See POSIX Safety Concepts.
The
putc_unlockedfunction is equivalent to theputcfunction except that it does not implicitly lock the stream.
Preliminary: | MT-Safe race:stream | AS-Unsafe corrupt | AC-Unsafe corrupt | See POSIX Safety Concepts.
The
putwc_unlockedfunction is equivalent to theputwcfunction except that it does not implicitly lock the stream.This function is a GNU extension.
Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe corrupt lock | See POSIX Safety Concepts.
The
putcharfunction is equivalent toputcwithstdoutas the value of the stream argument.
Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe corrupt lock | See POSIX Safety Concepts.
The
putwcharfunction is equivalent toputwcwithstdoutas the value of the stream argument.
Preliminary: | MT-Unsafe race:stdout | AS-Unsafe corrupt | AC-Unsafe corrupt | See POSIX Safety Concepts.
The
putchar_unlockedfunction is equivalent to theputcharfunction except that it does not implicitly lock the stream.
Preliminary: | MT-Unsafe race:stdout | AS-Unsafe corrupt | AC-Unsafe corrupt | See POSIX Safety Concepts.
The
putwchar_unlockedfunction is equivalent to theputwcharfunction except that it does not implicitly lock the stream.This function is a GNU extension.
Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe corrupt lock | See POSIX Safety Concepts.
The function
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
EOFif 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.
Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe corrupt lock | See POSIX Safety Concepts.
The function
fputwswrites the wide character string ws 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
WEOFif a write error occurs, and otherwise a non-negative value.
Preliminary: | MT-Safe race:stream | AS-Unsafe corrupt | AC-Unsafe corrupt | See POSIX Safety Concepts.
The
fputs_unlockedfunction is equivalent to thefputsfunction except that it does not implicitly lock the stream.This function is a GNU extension.
Preliminary: | MT-Safe race:stream | AS-Unsafe corrupt | AC-Unsafe corrupt | See POSIX Safety Concepts.
The
fputws_unlockedfunction is equivalent to thefputwsfunction except that it does not implicitly lock the stream.This function is a GNU extension.
Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe lock corrupt | See POSIX Safety Concepts.
The
putsfunction writes the string s to the streamstdoutfollowed by a newline. The terminating null character of the string is not written. (Note thatfputsdoes not write a newline as this function does.)
putsis the most convenient function for printing simple messages. For example:puts ("This is a message.");outputs the text ‘This is a message.’ followed by a newline.
Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe lock corrupt | See POSIX Safety Concepts.
This function writes the word w (that is, an
int) to stream. It is provided for compatibility with SVID, but we recommend you usefwriteinstead (see Block Input/Output).