Hi,
Is there a quick way of checking the data type of things?
I use a cin to get user input, and the thing that it's stored to is defined to be an integer. However, if I input things that are not integers, like "INTEGER", it goes crazy.
That is, I do something like this:
1 2 3 4 5
|
int number;
while(number!=1 && number!=0)
{
cin >> number;
}
|
What happens is that if I input integers, it behaves reasonable, but if I input other kinds of things it just loops forever without stopping.
Thus, I wanted to write a couple of quick lines that checks if the input is indeed an integer (which is what I need), and if not, rejects the input.
Is that something that can be checked relatively easily (or in any way)?
Thanks!