Command Prompt for Windows

getchar, _getwchar, gettchar

int getchar(void);
int _getwchar(void);
int gettchar(void);

Get a character.


On success, a character value is returned, on error or end of file, a value of EOF (ie. -1) is returned.


Function getchar(), _getwchar() and gettchar() is streamable, that is, when stdin is redirected on the command line from a file, the characters will be read from the file and will not be echoed to the screen.

When stdin has NOT been redirected on the command line then the following applies :-

1. Characters are echoed to the screen.

2. Tab characters are converted to single space characters,

3. Carriage return characters are converted to new line characters (ie. '\r' mapped to '\n').

4. All non-printable characters are ignored.

See Also

scanf, getch, putch, putchar