I'm writing some simple console program and I want to make sure that the value the user enters will only be a number, and if they accidently put in a letter, it will ask them for the number again.
How do I make a statement to reject every type of input but numbers? Moreover, how can I filter different data types taken in as a variable?
The litmus is usually just to try and translate the string to whatever your data is. For numbers, try turning it into a number. If it fails then it is not a number. Here's an example I recently posted: http://www.cplusplus.com/forum/beginner/4421/page1.html#msg19536