【发布时间】:2017-01-13 11:41:40
【问题描述】:
我想检查一个定义字符串 (cin) 中几个单词的 if 语句,以便它接受不同的大写和小写首字母的使用。
#include <iostream>
using namespace std;
int main()
{
string BothMods;
cout << "Are both online?" << endl;
cin >> BothMods;
if (BothMods == "Yes", "YES", "yes"{
cout <<"Both are online" << endl;
...
但是当我输入三个条件之一时,条件总是为假(否则会被执行)。如果我只使用一个(比如 if (BothMods == "Yes") ),它就可以工作。
【问题讨论】:
标签: c++ string if-statement cin