GeekInterview.com
Series: Subject: Topic:
Question: 21 of 587

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???
Asked by: Ruhani Chawlia | Member Since Jul-2010 | Asked on: Jul 10th, 2012

View all questions by Ruhani Chawlia   View all answers by Ruhani Chawlia

Showing Answers 1 - 1 of 1 Answers
jbode

Answered On : Aug 31st, 2012

View all answers by jbode

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.

  
Login to rate this answer.

Give your answer:

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

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.