What’s difference between getch() and getche() in C language? Which one is used when? What difference it will make in program?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people's questions, and connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Ravi Ujjwal
Both these functions reads character data type from input in the C program. They both are unformatted console I/O functions which is not present in the <iostream.h> but present in <conio.h>. We don’t need to press the ‘Enter’ key after the character is entered unlike scanf(). Also, both of these takes only one character as input.
getch()
When the character is entered it is not displayed on monitor and the character we entered is returned by this function’s definition which can be assigned to some char variable in our program.
It gives output without any buffer.
It doesn’t have echo on screen.
getche()
Working of getche() function is same as getch() except the fact that it does display the character entered by user on monitor.
Gives output with buffer.
It has echo on screen when returned.
Hope your doubts are cleared.