我试图让while循环工作,但由于某种原因,它会自动“假设”用户输入错误。如何比较char或string变量是否等于某个字符串?
value
是一个字符串(它应该是一个字符?) A
,B
,C
是字符串(他们应该是char?)
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'很棒。 – 2013-02-26 19:46:51