What is the difference between getch() and getche()?

What is the difference between getch() and getche() in C programming?

Your Answer

getch():
getch() is a nonstandard function and is present in conio.h header file which is mostly used by MS-DOS compilers like Turbo C. 
it reads  a single character from keyboard. But it does not use any buffer, so the entered character is immediately returned without waiting for the enter key.
Syntax:
int getch();
#include <stdio.h>
#include <conio.h>
int main()
{
printf("%c", getch());
return 0;
}
Input: g (Without enter key)
Output: Program terminates immediately.
But when you use DOS shell in Turbo C,
it shows a single g, i.e., 'g'
getche()
Like getch(), this is also a non-standard function present in conio.h. It reads a single character from the keyboard and displays immediately on output screen without waiting for enter key.
Syntax:
int getche(void);
#include <stdio.h>
#include <conio.h>
// Example for getche() in C
int main()
{
printf("%c", getche());
return 0;
}
Input: g(without enter key as it is not buffered)
Output: Program terminates immediately.
But when you use DOS shell in Turbo C,
double g, i.e., 'gg'

C Language

Didn't get the answer.
Contact people of Talent-C Language directly by clicking here