getc(3s)
NAME
getc, getchar, fgetc, getw − get character or word from stream
SYNTAX
#include <stdio.h>
int getc(stream)
FILE *stream;
int getchar()
int fgetc(stream)
FILE *stream;
int getw(stream)
FILE *stream;
DESCRIPTION
The getc function returns the next character from the named input stream.
The getchar function is identical to getc (stdin).
The fgetc function behaves like getc, but is a genuine function, not a macro. It may be used to save object text.
The getw function returns the next word (in a 32-bit integer on a VAX-11) 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() should be used to check the success of getw. The getw assumes no special alignment in the file.
RESTRICTIONS
Because it is implemented as a macro, getc treats a stream argument with side effects incorrectly. In particular, ‘getc(*f++);’ doesn’t work as expected.
DIAGNOSTICS
These functions return the integer constant EOF at end of file or upon read error.
A stop with message, ‘Reading bad file’, means an attempt has been made to read from a stream that has not been opened for reading by fopen.
SEE ALSO
fopen(3s), fread(3s), gets(3s), putc(3s), scanf(3s), ungetc(3s)