Why not create another function that is responsible for receiving user input? This way you can keep the code used to clear the input buffer all in one place.

For instance, have a function that...