C ++ If Statement Letter Reader

时间:2017-10-12 02:49:19

标签: c++

我正在努力使它成为你可以说是或是的,如果你想要一个教程,但它总是运行'cout'为教程如何修复if语句,使其成为我可以输入是或否的地方它将取决于我所说的,请告诉我为什么我必须做我必须做的事情。

#include <iostream>
#include <istream>
#include <string>
using namespace std;

int main(){
string name;
cin >> name;
cout << name << " Will Now Be Your Business Name";
cout << " Would You Like A Tutorial? ";
string input;
cin >> input;
if (input != "Yes" || "yes"){
    cout << "You First Start With Naming Your Business Which Is What You Did And Then You \nCreate A Product By Entering In 'Create_Project' This Is How You Make Money ";
}
else if (input != "No" || "no"){
    int money = 1000;
    cout << "Money: " << money;
    }
}

1 个答案:

答案 0 :(得分:0)

if (input != "Yes" || "yes")

你想要

if (input != "Yes" || input != "yes")  

否则,&#34;是&#34;不与输入进行比较,而是作为条件本身进行评估,并且由于C ++的工作原理是正确的(即非假)。
更详细的,在某种程度上不是0的任何东西都是真的。对于字符串&#34; yes&#34;,将获取内存地址,并且它不是0.