getwchar
, getwchar_unlocked
—read a wide character from standard input#include <wchar.h> wint_t getwchar(void); #define _GNU_SOURCE #include <wchar.h> wint_t getwchar_unlocked(void); #include <wchar.h> wint_t _getwchar_r(struct _reent *reent); #include <wchar.h> wint_t _getwchar_unlocked_r(struct _reent *reent);
Description
getwchar
function or macro is the wide character equivalent of
the getchar
function. You can use getwchar
to get the next
wide character from the standard input stream. As a side effect,
getwchar
advances the standard input's current position indicator.
getwchar_unlocked
is a non-thread-safe version of getwchar
.
getwchar_unlocked
may only safely be used within a scope
protected by flockfile() (or ftrylockfile()) and funlockfile(). This
function may safely be used in a multi-threaded program if and only
if they are called while the invoking thread owns the (FILE *)
object, as is the case after a successful call to the flockfile() or
ftrylockfile() functions. If threads are disabled, then
getwchar_unlocked
is equivalent to getwchar
.
The alternate functions _getwchar_r
and _getwchar_unlocked_r
are
reentrant versions of the above. The extra argument reent is a pointer to
a reentrancy structure.
Returns
wint_t
, unless there is no more
data, or the host system reports a read error; in either of these
situations, getwchar
returns WEOF
.
You can distinguish the two situations that cause an WEOF
result by
using `ferror(stdin)
' and `feof(stdin)
'.
Portability
getwchar
is required by C99.
getwchar_unlocked
is a GNU extension.