C <wchar.h> - putwchar() Function
The C <wchar.h> putwchar() function writes a wide character wc to the output stream stdout. It is equivalent to calling putwc() function with stdout as second argument.
If the wide character cannot be represented using the multibyte encoding, the function returns WEOF and sets errno to EILSEQ.
If a writing error occurs, the function returns WEOF and sets the error indicator for the stream ferror().
Syntax
wint_t putwchar (wchar_t wc);
Parameters
wc |
Specify a wide character to be written. |
Return Value
On success, the character wc is returned. On writing error, returns WEOF and sets the error indicator ferror(). On encoding error, returns WEOF and sets errno to EILSEQ.
Example:
The example below shows the usage of putwchar() function.
#include <stdio.h> #include <wchar.h> int main (){ //prints wide characters for(wchar_t wc = L'A'; wc <= L'Z'; wc++) putwchar(wc); return 0; }
The output of the above code will be:
ABCDEFGHIJKLMNOPQRSTUVWXYZ
❮ C <wchar.h> Library