+ 8

why does it return an int

in c getchar() and getc() return int but all values that they return can be returned as a char is there any logical reason for that

15th Jun 2019, 10:03 AM
ABADA S
ABADA S - avatar
6 Answers
+ 7
Yes...It actually return the ASCII value of charachar which is integer.
15th Jun 2019, 12:23 PM
A͢J
A͢J - avatar
+ 5
Tushar post this question in seperate thread.
15th Jun 2019, 1:39 PM
A͢J
A͢J - avatar
+ 5
Because EOF which is one possible return value does not lie within the ASCII range.
15th Jun 2019, 10:41 PM
Sonic
Sonic - avatar
+ 4
Maroon (AJ AY) (Traveling) char also stores the ASCII value which is integer but this integer is between -128 and 127
15th Jun 2019, 12:26 PM
ABADA S
ABADA S - avatar
+ 3
Sonic I accept that but it can stored in char check this char f(){return EOF;} this function return a char and can return EOF easily
16th Jun 2019, 7:22 AM
ABADA S
ABADA S - avatar
+ 1
How to be the best coder
15th Jun 2019, 1:35 PM
Tushar
Tushar - avatar