GETC - get a character from input.

(ANSI Standard)


#include <stdio.h>
i = getc( f );


FILE *f;
points to the file to be read.
int i;
is the character that is read in.


"getc" returns the next character from the file "f". The function returns EOF when end-of-file has been encountered or upon a read error.

When the data is being read from a terminal, the terminal user can generate an end of file condition by entering a line consisting of CTRL-\ (hold down the CTRL key and press the backslash), followed immediately by a carriage return. This is the ASCII file separator (FS) character. (Note that this is different from UNIX which uses the CTRL-D (EOT) character to signify end-of-file.)


Except for Media 4 files, "getc" ignores any null characters (NUL, '\0') found in the input. For example, if "getc" reads a null character from a Media 6 file, it does not return; instead, it keeps reading until it finds a non-null character, then returns that character to the caller.

See Also:

expl c lib getchar

expl nsc lib getchar

Copyright © 1996, Thinkage Ltd.