Getch function declaration

Can you please explain the declaration of getch() function that is "int getch(void)"?
I have the doubt that if its return type is int, why is the character typed from the keyboard is displayed as it is? It should be displayed in its ASCII value. Also, what does void as parameter in this function stand for???

Questions by Ruhani Chawlia   answers by Ruhani Chawlia

Showing Answers 1 - 1 of 1 Answers

In C, all the character-oriented functions (getc, fgetc, getchar, etc.) return int instead of char, mainly to support an out-of-band value for EOF (an integer expression with a negative value).

The "void" in the parameter list indicates that the function takes no parameters.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions