GETC(3P)GETC(3P)NAME
getc, getchar, fgetc - get character from stream
SYNOPSIS
#include <stdio.h>
int getc(FILE *stream);
int getchar(void);
int fgetc(FILE *stream);
(ALSO AVAILABLE IN BSD)
int getw(FILE *stream);
DESCRIPTION
Getc returns the next character from the named input stream.
Getchar is identical to getc(stdin).
Fgetc behaves like getc, but is a genuine function, not a macro; it may
be used to save object text.
RETURN VALUE
Getc, getchar, and fgetc return the next character from the input
stream. If the stream is at end-of-file, the end-of-file indicator for
the stream is set then EOF is returned. If a read error occurs, the
error indicator for the stream is set and EOF is returned.
Getw returns the next int from the named input stream. It returns the
constant EOF upon end of file or error, but since that is a good
integer value, feof and ferror(3S) should be used to check the success
of getw. Getw assumes no special alignment in the file. Getw is not
an ANSI C function (nor is it POSIX-compliant).
ERRORS
The underlying function of getc, getchar, and fgetc is read(2P). The
error conditions specified for read (2P) apply to getc, getchar, and
fgetc.
BUGS
Because it is implemented as a macro, getc treats a stream argument
with side effects incorrectly. In particular, `getc(*f++);' doesn't
work sensibly.
SEE ALSOread(2), clearerr(3S), fopen(3S), putc(3S), gets(3S), scanf(3S),
fread(3S), ungetc(3S)
August 1, 1992 GETC(3P)