这是我的游戏的功能,它会要求输入和cin到"iAuswahl"!然后while循环检查它是否是我想要1-9的值之一,如果不是它激活并且应该要求新输入.巫婆为int做的.但是,如果我输入一个类似r的字符,它会变得疯狂,只是继续给我回来我的cout并跳过cin!我的问题是它为什么这样做,我如何阻止它?
void zug(string sSpieler, int iDran){
int iAuswahl;
char cXO = 'O';
if (iDran == 1)
{
cXO = 'X';
}
cout << sSpieler << ", Sie sind am Zug. Bitte waehlen sie eins der Felder.\n" << endl;
grafik();
cout << "Sie sind >> " << cXO << " <<." << endl;
cin >> iAuswahl;
cout << endl;
while (
iAuswahl != 1
&& iAuswahl != 2
&& iAuswahl != 3
&& iAuswahl != 4
&& iAuswahl != 5
&& …Run Code Online (Sandbox Code Playgroud)