Why does getchar return a value of type int?
-
A
To allow it to read wide characters
-
B
To make it faster than putchar
-
C
So that EOF can be told apart from data
Correct answer
-
D
Because characters are stored as int
Correct answer
C. So that EOF can be told apart from data
13 views
Explanation
getchar returns an int so that the out-of-band value EOF cannot be mistaken for any real character.
Reference
Asked in: NTS, PPSC IT, Campus Interviews
Doubts & discussion
Not sure why the answer is C? Ask here and get an explanation.
Ask a doubt about this MCQ