为什么当输入错误输入时无限循环?我该如何纠正?当输入错误输入时无限循环无限循环
int operation;
while (true) {
cout << "What operation would you like to perform? Enter the number corresponding to the operation you would like to perform. ";
cin >> operation;
if (operation >= 1 && operation <= 5) break;
cout << "Please enter a number from 1 to 5, inclusive.\n";
}
这看起来与您最近问的问题非常相似。另一个问题发生了什么? – 2010-10-06 19:20:50
啊,发布它的人不一样。这解释了为什么我找不到它! – 2010-10-06 19:30:19