【发布时间】:2013-02-26 19:40:51
【问题描述】:
我正在尝试让这个 while 循环工作,但由于某种原因,它会自动“假定”用户输入错误。
value 是一个字符串(应该是一个字符吗?)
A,B,C 是字符串(应该是字符吗?)
void Course::set()
{
cout << "blah blah blah" << endl;
cout << "youre options are A, B, C" <<endl;
cin >> value;
while(Comp != "A" || Comp != "B" || Comp != "C")
{
cout << "The character you enter is not correct, please enter one of the following: You're options are A, B, C" << endl;
cin >> value;
}
cout << endl;
}
【问题讨论】:
-
不,它们不应该是
char,std::string很棒。
标签: c++ comparison string-comparison logical-operators