The two functions getch() and getche() are very similar, as they respond without pressing the Enter key. The difference is that with the function getche() the echo of the pressed key is displayed on the screen (the letter “e” stands for “echo”), but with the function getch(), there is no echoing. The program shown in the figure 1 demonstrates the use of both functions. Similarly, the program shown in the figure 3 demonstrate the difference between getche(), getch(), and getchar() function.
getchar() function reads one character from the keyboard after the new line character is received, when we press Enter key. The program shown in figure 2 demonstrates the use of the function getchar(). It begins with declaring an integer variable “ascii”, then the function itself is assigned to this variable.
This means that the character received by the function will be contained in the variable “ascii”. The first printf() function displays the contents of the variable “ascii” in the character format (%c) preceded by the string “the character”. The second printf() function displays the same variable in the decimal format (%d) preceded by the string corresponds to the ASCII.