陷入Infinite While Loop,该怎么做

-3 c++ loops infinite while-loop

这不接受任何答案:

cout << "Restart yes or no: ";
cin >> retry;
while (retry != "yes" or retry != "no"){
    cout << "Restart yes or no: ";
    cin >> retry;
    system("cls");
}
Run Code Online (Sandbox Code Playgroud)

如果任何人可以提供替代/修复,将不胜感激.

Mur*_*nik 6

每个字符串都不同于"yes""no".你的意思是环路,只要该字符串从不同的是这两个 "yes""no"-这意味着使用逻辑"与"操作,而不是"或"运算符:

while (retry != "yes" && retry != "no") {
Run Code Online (Sandbox Code Playgroud)