Your Browser is not longer supported
Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...
{{viewport.spaceProperty.prod}}
getchar - Read a character from standard input
&pagelevel(4)&pagelevel
Definition | #include <stdio.h> int getchar(void); getchar reads a character from the standard input (file pointer stdin ).
|
Return val. | Character read as a positive integer value |
| if successful. |
EOF | for end of file or error. |
Notes | getchar is implemented both as a macro and as a function (see section “Functions and macros”).
If you use a comparison such as while((c = getchar()) != EOF) in your program, the variable c must always be declared as an integer . If you define c as a char , the EOF condition is never satisfied for the following reason: -1 is converted to char ’0xFF’ (i.e. +255); EOF, however, is defined as -1. You can satisfy the EOF condition when reading from the terminal by means of the following actions: pressing the K2 key and entering the system commands EOF and RESUME-PROGRAM. |
See also | getc, fgetc, getwchar |