This post will explain major difference between getch(),
getche() and getchar() functions. All of these functions get character input
from user.
Generally it is determined that getch() function is
used to
freeze console output. But it happens because whenever getch() function
is called it waits for input of keyboard. Until the input is given getch()
freezes the output screen. After getting input from user program continues.
getche() also takes character input from keyboard and it
also freezes output screen but the difference between getch() and getche() is
that getche() displays the character which is inputted by the user whereas
getch() does not display the inputted character.
Functioning of getchar() is same as getche() . It also shows
the inputted key. But getchar() takes input from user until Enter key is pressed.
This getch() program will terminate after getting any key as input.
This getche() program will also terminate after getting any key as input but it will display the key which you will press. You can see the output window again using Alt+F5 key combination. If you will try to see the output of above program then you will see nothing because getch() does not show the pressed key.
This getchar() program will terminate when you will press Enter key. Till then it will continue showing the pressed keys.