c ++来自string的特定单词

时间:2017-01-13 11:41:41

标签: c++ string if-statement cin

我想从定义的字符串(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 ==&#34;是&#34;))它可以工作。

1 个答案:

答案 0 :(得分:2)

如果要检查多个案例,则需要使用OR运算符单独检查每个案例。

require "db.php";
$query = mysqli_query($conn, 'SELECT level, shelf_no, bin_id FROM location_bin ORDER BY shelf_no asc, level asc ');

echo "<table border='1'>";
echo "<tr>";
$i=0;

while($res = mysqli_fetch_assoc($query)) {
    $row=$res['shelf_no'];
    if ($i < $row){
            $i=$row;
        echo "</tr><tr>";

    }

    echo "<td>".$res['bin_id']."</td>";



    }


echo "</table>";

?>