getche()
getche() function reads a single character from the keyboard and displays immediately on the output screen without waiting for enter key. Like getch(), it is also a non-standard function present in <conio.h> header file.
Syntax
int getche(void);
Example
C
// Example for getche() in C #include <conio.h> #include <stdio.h> 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'
Difference between getc(), getchar(), getch() and getche()
All of these functions read a character from input and return an integer value. The integer is returned to accommodate a special value used to indicate failure. The value EOF is generally used for this purpose.