我有一个输入验证的快速问题。我有我的循环,它适用于负数,但是当我输入类似+符号的东西时,它会导致无限循环。有什么办法可以解决吗?
cout << "Input Quarter 1 Sales: " << endl;
cin >> quarter1;
while (quarter1 < 0)
{
cout << "Error! Sales Must be a Positive Number!" << endl;
cout << "Please Input a Positive Number" << endl << endl;
cin >> quarter1;
}