我在尝试检查if语句中的多种可能性时遇到了问题.
用户输入一个字符串,然后我针对多种可能性检查该字符串.
if (theString == "Seven" || "seven" || "7")
{
theInt = 7;
cout << "You chose: " << theInt << endl;
}
else if (theString == "Six" || "six" || "6")
{
theInt = 6;
cout << "You chose: " << theInt << endl;
}
Run Code Online (Sandbox Code Playgroud)
所以这只是我想要完成的一个简单的例子.在我的程序中,这些if语句在函数中,我正在使用#include [string].(我甚至不确定"6"或"7"是否可行,但我现在甚至无法测试我的代码:(所以现在在我的代码中,如果用户输入6,我的程序将运行并分配任何想法都是7的值.
谢谢.