嘿,我試圖驗證一個字符,以限制它對男性或女性的m或f進行校正。但即使在m或f被按下的情況下它也不會通過while條件,並且不斷循環這個問題。Char驗證器不僅會接受大寫和小寫M/F
任何人可以幫助我。 在此先感謝。 這裏是我的代碼:
char Validator :: getChar(string q)
{
char input;
do
{
cout << q.c_str() << endl;
cin >> input;
}
while(!isalpha(input) && "M"||"F"||"m"||"f");
return input;
}
,完美的工作非常感謝。而你的權利我認爲會有效果,而且從現在開始我會有所不同。 – Pendo826