Default return-type of getchar() - int - C programming

Q.  What is the default return-type of getchar()? (C programming)
- Published on 26 Jun 15

a. char
b. int
c. char *
d. Reading character doesn't require a return-type

ANSWER: int
 
The getchar needs to remove some abnormal state. Say for example read error or end of file (EOF = -1). Here the returned value is not 0-255 so It is not possible to represent such cases with char type.

Post your comment / Share knowledge


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)