Hi guys , so I just started learning C++ so I am trying to do something but id does not turn out quite how I want it to be.
So my idea is to create a text game and I'm at the very beggining and I have a lot of stuff to learn before I can realize it ,but there is a problem that is just eating at me right at the beggining. So I will post my project and say what the problem is:

#include <iostream>
#include <string>

using namespace std;

int main()
{
    cout << "Welcome to the world of wonders where anything can happen!" << endl;
    cout << "And your name is? ";
    string name;
    getline (cin,name);
    cout<< "Hi "<< name << " ready to begin your journey?";
    string yon;
    getline (cin, yon);
    if (yon == "yes"||"no"||"Yes"||"No")
    {
        cout<<"Test";
    }
    else
        cout<<"I had expected the answers Yes or No, because you answered something else you fall into a bottomless pit.";
    return 0;
}

So because I want to get only Yes or No answers I though of this way of "killing" the player in the beggining (in the future I plan on learning how to send the player back to the question on which he died and not just end the proggram) so to get to the Yes/No if statement I need to get the Yes,No/Anything else statement first, but if its just if (yon == "yes") it works fine and as soon as I add the other conditions it bugs out and just accepts everything as true. I hope you guys can actualy understand what I want to do and can help me :D

how about if (yon == "yes")||(yon =="no")||(yon=="Yes")||(yon =="No")

It workeed ^_^ Well I had to add all that in a bigger bracket like this :

if ((yon == "yes")||(yon =="no")||(yon=="Yes")||(yon =="No"))

but in the end it worked. Thanks a lot !!! ^_^

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.