Name
getwc
Synopsis
Reads a wide character from a file
#include <stdio.h> #include <wchar.h> wint_tgetwc
( FILE *fp
);
The getwc()
function is the
wide-character counterpart to getc()
: it may be implemented as a macro,
and may evaluate its argument more than once, causing unforeseen
side effects. Use fgetwc()
instead.
getwc()
returns the
character read. A return value of WEOF
indicates an error or an attempt to
read past the end of the input stream. In these cases the function
sets the error or end-of-file flag for stdin
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 =getwc
( stdin)) != WEOF ) { wc = towupper(wc);putwc
( (wchar_t)wc, stdout); }
Get C in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.