I saw other SO questions regarding input format validation, however I am looking for a more specific answer to the question I have.
Currently, I need to read 2 integer values and save them as coordinates. I used:
cin >> x >> y
which will read the x and y values, separated by a space.
However, any input other than
int whitepsace int
will destroy my program. I tried to check the input to ensure that each value is an integer, however it only applies to the first integer input.
I also need to make sure that the input format remains as int whitespace int, so that I can consistently use the values in my program.
Any ideas?
Things I tried with no luck:
- do - while w/
cin.fail() max(). isDigit()