Reads a wide character from the standard input stream #include <wchar.h> wint_t getwchar( void ); The getwchar( ) function is the wide-character counterpart to getchar( ); it is equivalent to getwc( stdin ) and returns the wide character read. Like getwc( ), getwchar( ) may be implemented as a macro, but because it has no arguments, unforeseen side effects are not likely. A return value of WEOF indicates an error or an attempt to read past the end of the file. In these cases, the function sets the file's error or end-of-file flag as appropriate. Example
wint_t wc;
if ( setlocale( LC_CTYPE, "" ) == NULL)
{
fwprintf( stderr,
L"Sorry, couldn't change to the system's native locale.\n");
return 1;
}
while ( (wc = getwchar( )) != WEOF ) // or: (wc = getwc( stdin))
{
wc = towupper(wc);
putwchar((wchar_t)wc); // or: putwc( (wchar_t)wc, stdout);
}
See Alsofgetwc( ); the byte-character functions getc( ) and getchar( ); the output functions fputwc( ) and putwchar( ) |