### getwc -- Read Wide Character from Stream

Format

>     #include <stdio.h>
>     #include <wchar.h>
>     wint_t getwc(FILE *stream);

Language Level: ANSI 93, XPG4
getwc reads the next multibyte character from stream, converts it to a wide character, and advances the associated file position indicator for stream.

getwc is equivalent to fgetwc except that, if it is implemented as a macro, it can evaluate stream more than once. Therefore, the argument should never be an expression with side effects.

The behavior of getwc is affected by the LC_CTYPE category of the current locale. If you change the category between subsequent read operations on the same stream, undefined results can occur.

Using non-wide-character functions with getwc on the same stream results in undefined behavior.

After calling getwc, flush the buffer or reposition the stream pointer before calling a write function for the stream, unless EOF has been reached. After a write operation on the stream, flush the buffer or reposition the stream pointer before calling getwc.

Return Value
getwc returns the next wide character from the input stream, or WEOF. If an error occurs, getwc sets the error indicator. If getwc encounters the end-of-file, it sets the EOF indicator. If an encoding error occurs during conversion of the multibyte character, getwc sets errno to EILSEQ.

Use ferror or feof to determine whether an error or an EOF condition occurred. EOF is only reached when an attempt is made to read past the last byte of data. Reading up to and including the last byte of data does not turn on the EOF indicator.

Example

fgetwc -- Read Wide Character from Stream
getwchar -- Get Wide Character from stdin
getc - getchar -- Read a Character
_getch - _getche -- Read Character from Keyboard
putwc -- Write Wide Character
<stdio.h>
<wchar.h>