|HP-UX Reference > P
putwc(3C)HP-UX 11i Version 3: February 2007
putwc(), putwchar(), fputwc() — put a wide character on a stream file
wint_t putwc(wint_t wc, FILE *stream);
wint_t putwchar(wint_t wc);
wint_t fputwc(wint_t wc, FILE *stream);
wint_t putwc(wchar_t wc, FILE *stream);
wint_t putwchar(wchar_t wc);
wint_t fputwc(wchar_t wc, FILE *stream);
wint_t putwc_unlocked(wint_t wc, FILE *stream);
wint_t putwchar_unlocked(wint_t wc);
wint_t fputwc_unlocked(wint_t wc, FILE *stream);
These functions are compliant with the XPG4 Worldwide Portability Interface wide-character I/O functions. They parallel the 8-bit character I/O functions defined in putc(3S).
Output streams, with the exception of the standard error stream stderr, are by default buffered if the output refers to a file and line-buffered if the output refers to a terminal. The standard error output stream, stderr, is by default unbuffered, but use of freopen() (see fopen(3S)) causes it to become buffered or line-buffered. setbuf() or setvbuf() (see setbuf(3S)) can be used to change the stream's buffering strategy.
Definitions for these functions, the type wint_t and the value WEOF are provided in the <wchar.h> header.
To use the _INCLUDE__STDC_A1_SOURCE prototype, the _INCLUDE__STDC_A1_SOURCE flag must be passed as a compiler option or defined as a macro in source files.
After fputwc(), putwc(), or putwchar() is applied to a stream, the stream becomes byte-oriented (see orientation(5)).
On success, putwc(), putwc_unlocked(), fputwc(), fputwc_unlocked(), putwchar(), and putwchar_unlocked() each return the wide character corresponding to the value they have written. On failure, they return the constant WEOF, set the error indicator for the stream, and set errno to indicate the error.
putwc(), putwc_unlocked(), putwchar(), putwchar_unlocked(), fputwc(), and fputwc_unlocked() fail if either the stream is unbuffered, or stream's buffer needed to be flushed causing an underlying write() call to be invoked, and:
Additional errno values can be set by the underlying write() function (see write(2)).
Line buffering may cause confusion or malfunctioning of programs that use wide character I/O routines but use read() themselves to read from standard input. When a large amount of computation is done after printing part of a line on an output terminal, it is necessary to fflush() (see fclose(3S)) the standard output before beginning the computation.
putwc_unlocked(), putwchar_unlocked() and fputwc_unlocked() are obsolescent interfaces supported only for compatibility with existing DCE applications. New multithreaded applications should use putwc(), putwchar() and fputwc().
fclose(3S), ferror(3S), flockfile(3S), fopen(3S), getwc(3C), fread(3S), printf(3S), putws(3C), setbuf(3S), orientation(5), thread_safety(5).