So here is what I have:
The user enters a number into an int. Now, I've solved if the user enters a character first, however, if there is a number first, I can't seem to figure out how to detect it.
So if the user enters a123, the programs returns an error.
But if the user enters 123a, then no error is returned. Instead, 123 is put into the int, and a is left to be caught the next time around, as if the user entered a123 the second time.
So what I need to detect is if there is any buffer left. Kinda like using sync, but if I use that, then it clears it, and then tells me that it was there, so that doesn't help because I need it left in the buffer, which should explain itself in part of my program run below.
I've added commentsfor clarifacation
Please enter number of A's: 12 //valid input
Please enter number of B's: a12 //Bad input
Error! "a12" is invalid. //Bad input told to user
Please enter a valid number: 12 //valid input
Please enter number of C's: 12a //Invalid input, yet C is gived valud of 12
Please enter number of D's: Error! "a" is invalid. //D gets left buffer of 'a'
Please enter a valid number:
As you see, C gets 12, and then D goes to run, but then gets the buffer of 'a' and returns an error.