So the simple program below asks the user to enter an integer greater than ro equal to 0. If the user enters in a negative integer or a character (a letter, dot, dash etc..), the buffer clears, the invalid input is ignored and the message is repeated. This continues as long as the number entered is negative or the something other than an integer is entered.
The problem is, if multiple character are entered, the message is also repeated multiple times. How can one fix this so that no matter how many characters are entered the message only repeats once?
For example: If the user enters the characters 'fg/ab', I want the "Enter an integer zero or greater: " message to be only repeated once and NOT 5 times like it does here.