Syntax
#include <wchar.h> wint_t putwchar(wchar_t wc);Description
putwchar converts the wide character wc to a multibyte character and writes it to stdout. A call to putwchar is equivalent to putwc(wc, stdout).
The behavior of putwchar is affected by the LC_CTYPE category of the current locale.
After calling putwchar, flush the buffer or reposition the stream pointer before calling a read function for the stream, unless EOF has been reached. After a read operation on the stream, flush the buffer or reposition the stream pointer before calling putwchar.
putwchar returns the wide character written. If a write error occurs, putwchar sets the error indicator for the stream and returns WEOF. If an encoding error occurs when a wide character is converted to a multibyte character, putwchar sets errno to EILSEQ and returns WEOF.
This example uses putwchar to write the string in wcs.
#include <stdio.h>
#include <wchar.h>
#include <errno.h>
#include <stdlib.h>
int main(void)
{
wchar_t *wcs = L"A character string.";
int i;
for (i = 0; wcs[i] != L'\0'; i++) {
errno = 0;
if (WEOF == putwchar(wcs[i])) {
printf("Unable to putwchar() the wide character.\n");
printf("wcs[%d] = 0x%lx\n", i, wcs[i]);
if (EILSEQ == errno)
printf("An invalid wide character was encountered.\n");
exit(EXIT_FAILURE);
}
}
return 0;
/****************************************************************************
The output should be similar to :
A character string.
****************************************************************************/
}
Related Information