任何人都可以在這個循環中發現我的錯誤嗎?在我閱讀答覆後,我似乎被卡在If語句中。此外,將打破退出沒有條件爲真循環似乎引發錯誤:陷入while語句中的if語句
代碼「事情之前預期的主要表現」:
while (rowNum > (FC_Row))
{
cout << "That row is not located in our first class section. Would you like to change your class so you can sit in that row (Y/N)?" << endl;
cin >> reply;
reply = toupper(reply);
while (reply != 'Y' && reply !='N')
{
cin.clear();
while(cin.get()!='\n');
cout << "Please indicate your answer with Y (yes) or N (no)." << endl;
cout << "try again:" << endl;
cin >> reply;
reply = toupper(reply);
}
if (reply == 'Y')
{
ticketType = 'E';
break;
}
else
{
cout << "Then choose a row numbered 1-" << (FC_Row) << endl;
cin >> rowNum;
}
}
謝謝你們,得看那些支架。
我假設這就是爲什麼他有「toupper」函數調用。 – dlanod 2011-03-12 19:43:53