NAME

getc, getchar, fgetc, getw - get character or word from stream

SYNOPSIS

#include <stdio_p.h>

int getc (strean)
FILE *stream;

int getchar ()

int fgetc (stream)
FILE *stream;

int getw (stream)
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 therefore be used as an argument. fgetc runs more slowly than getc, but takes less space per invocation.

getw returns the next word from the named input stream. It returns the constant EOF upon end of file or error, but since that is a valid integer value, feof and ferror(3P) should be used to check the success of getw. getw assumes no special alignment in the file.

SEE ALSO

ferror(3P) , fopen(3P) , fread(3P) , gets(3P) , putc(3P) , scanf(3P).

DIAGNOSTICS

These functions return the integer constant EOF at end of file or upon read error.

A stop with message "Reading bad file" means that an attempt has been made to read from a stream that has not been opened for reading by fopen.

BUGS

Because it is implememtned as a macro getc treats incorrectly a stream argument with side effects. In particular, getc(*f++) doesn't work sensibly.