GETC(3S)
NAME
getc, getchar, fgetc, getw − get character or word from stream
USAGE
#include <stdio.h>
int getc(stream)
FILE *stream;
int getchar()
int fgetc(stream)
FILE *stream;
int getw(stream)
FILE *stream;
DESCRIPTION
Getc returns the next character from the input stream.
Getchar() is identical to getc(stdin).
Fgetc operates like getc, but is an actual function, not a macro; it may be used to save object text.
Getw returns the next word (in a 32-bit integer) from the input stream. It returns the constant EOF upon end of file or upon an 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.
NOTES
The end of file return from getchar is incompatible with that in UNIX versions 1 through 6.
Because it is implemented as a macro, getc treats a stream argument with side effects incorrectly. Specifically, “getc(*f++);” doesn’t work correctly.
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.
RELATED INFORMATION
fopen(3S), putc(3S), gets(3S), scanf(3S), fread(3S), ungetc(3S)