GETCHAR - get a character from "stdin".

(ANSI Standard)


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


int i;
is the character that is read in.


"getchar" returns the next character from the standard input "stdin". 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, "getchar" ignores any null characters (NUL, '\0') found in the input. For example, if "getchar" 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 getc

expl nsc lib getc

Copyright © 1996, Thinkage Ltd.