Hi I wish that the following code can ask for an input of 2 integers within a certain range. If the condition is not satisfied, the loop kicks in until right numbers are typed in. The problem is that if I give a letter first (e.g. "r"), I will get an endless loop immediately (the system doesn't ask for the second but instead keeps showing "something wrong, please input again"). If the second input is a letter, the program can terminate. Could you tell me where goes wrong? Thanks very much.
#include <iostream>
int main()
{
int x, y;
std::cout << "Please input 2 integers in the range: \n";
std::cin >> x >> y;
while (! ((x >= 0) && (x < 10) &&
(y >= 0) && (y < 10)) )
{
std::cout << "\nsomething wrong, please input again\n";
std::cin >> x >> y;
}
}