When we get any character from the keyboard, so this procedure takes place.
- We enter a character from the keyboard.
- Characters entered are go in Standard Input Stream
- function like
getch() fetch that character from the Standard Input Stream, and not from the keyboard.
So, hitting Enter key after the character key, store Enter also in Standard Input Stream, so the next function
getch(), do not wait to get a character from the keyboard, but take the Enter key, hit previously from the Standard Input Stream. So, to solve this problem we have to clear our buffer completely before functions
getch(). This function is performed by