fgetwc(3S) fgetwc(3S)
NAME
fgetwc, getwc, getwchar - get a wide character code from a stream
SYNOPSIS
cc [flag ...] file ... -lw [library ...]
#include <stdio.h>
#include <wchar.h>
wintt fgetwc(FILE *stream);
wintt getwc(FILE *stream);
wintt getwchar(void);
DESCRIPTION
The fgetwc() function obtains the next character (if present) from the
input stream pointed to by stream, converts that to the corresponding
wide character code and advances the associated file position indica-
tor for the stream (if defined).
If an error occurs, the resulting value of the file position indicator
for the stream is indeterminate. The ferror() or feof() functions must
be used to distinguish between an error condition and an end-of-file
condition.
The getwc() function is equivalent to fgetwc(), except that if it is
implemented as a macro it can evaluate stream more than once, so the
argument should never be an expression with side-effects. In particu-
lar, getwc(*f++) may not work as expected. Therefore, use of this
function is not recommended; the fgetwc() function should be used
instead.
The function call getwchar() is equivalent to getwc(stdin). If the
value returned by getwchar() is stored into a variable of type wchart
and then compared against the wintt macro WEOF, the comparison may
never succeed.
The functions may mark the statime field of the file associated with
stream for update. The statime field will be marked for update by the
first successful execution of fgetc(), fgetws(), fread(), fscanf(),
getc(), getchar(), gets() or scanf() using stream that returns data
not supplied by a prior call to ungetc() or ungetwc().
ERRORS
The following error code descriptions are function-specific. You will
find a general description in introprm2(2) or in errno(5).
Page 1 Reliant UNIX 5.44 Printed 11/98
fgetwc(3S) fgetwc(3S)
The fgetwc() function will fail if data needs to be read and:
EAGAIN The ONONBLOCK flag is set for the file descriptor under-
lying stream and the process would be delayed in the
fgetwc() operation.
EBADF The file-descriptor underlying stream is not a valid file
descriptor open for reading.
EINTR The read operation was terminated due to the receipt of a
signal, and no data was transferred.
EIO A physical I/O error has occurred, or the process is in a
background process group attempting to read from the con-
trolling terminal, and either the process is ignoring or
blocking the SIGTTIN signal or the process group is
orphaned. This error may also be generated for implemen-
tation-dependent reasons.
EOVERFLOW The file is a regular file and an attempt was made to read
at or beyond the offset maximum associated with the cor-
responding stream.
The fgetwc() function will fail if:
ENOMEM Insufficient storage space is available.
ENXIO A request was made of a non-existent device, or the
request was outside the capabilities of the device.
EILSEQ The data obtained from the input stream does not form a
valid character.
RESULT
Upon successful completion the fgetwc() function returns the wide
character code of the character read from the input stream pointed to
by stream of type wint. If the stream is at end-of-file, the end-of-
file indicator for the stream is set and fgetwc() returns WEOF. If a
read error occurs, the error indicator for the stream is set, fgetwc()
returns a null pointer and sets errno to indicate the error.
SEE ALSO
feof(3S), ferror(3S), fopen(3S), lfs(5), stdio(5), wchar(5).
Page 2 Reliant UNIX 5.44 Printed 11/98