InterviewSolution
Saved Bookmarks
| 1. |
What is the difference between getch() and getche()? |
|
Answer» Both these C FUNCTIONS read CHARACTERS from the keyboard, the only DIFFERENCE being:
Here is an example to demonstrate the difference between the two functions: #include<stdio.h>#include<conio.h>int main(){ char c; printf("Enter a character here: "); c = getch(); printf("nYou entered the character: %c",c); printf("nEnter another character: "); c = getche(); printf("nYour new entered character is: %c",c); return 0;}Output: Enter a character here:You entered the character: cEnter another character: bYour new entered character is: bgetch() immediately returns the character without waiting for the enter key to be pressed and the character is not displayed on the screen. getche() displays the character on the screen without waiting for the enter key to be pressed. |
|