asd

/lsdfadsf
Last edited on
1
2
3
4
5
6
7
if (choice == "ESCAPE" || "escape" || "Escape")
    {    cout << "You ran to the door and broke it open with a hatchet you found in the closet." << endl;
        
        }
    else if (choice == "STAY" || "stay" || "Stay"){
        cout << "The ocean water broke through the window and you drowned :(\nGAME OVER!" << endl;    
    }


1
2
3
4
5
6
if (choice == "ESCAPE" || choice == "escape" || choice =="Escape") {
    cout << "You ran to the door and broke it open with a hatchet you found in the closet." << endl;
}
else if (choice == "STAY" || choice == "stay" || choice == "Stay"){
    cout << "The ocean water broke through the window and you drowned :(\nGAME OVER!" << endl;
}


You want to be careful when doing things like this.

1
2
if("someText") // it may not make sense, but this always evaluates true
  std::cout << "I'm going to be printed!\n";
to compare ignoring case, use a toupper or tolower on all input against your list of answers.
then you can even take it if the user typed EsCApE.

c++ conditions are explicit. to do what you said, you need
choice=="escape" || choice == "Escape" || choice == "ESCAPE"
like that.

what you have boils down to (as said above)
if (choice == "ESACPE" OR TRUE OR TRUE) which is true always.

Topic archived. No new replies allowed.