Not working?

Dec 22, 2014 at 11:42pm
I keep having this issue that if someone puts in an answer other than what is given, it will show a blank screen and they will have to restart the game... any ideas how to fix this? Here is the code that I put:

1
2
3
4
5
if(Answer!="Home"; Answer!="Shop"; Answer!="Fight"){
cout << "Sorry, this is not a valid function, please try again";
Sleep(1000);
Answer=Home;]
}
Dec 23, 2014 at 12:00am
Based on this and your other thread, I'd recommend going back to your textbook and re-read how to construct if statements with multiple conditions. You certainly don't use a ; symbol for logical and!
Dec 23, 2014 at 12:00am
learn c++, you have to use the logical "and" && to put multiple if parameters.
Dec 23, 2014 at 12:16am
If you use logical "and", won't the condition always be false since Answer cannot be both one thing and another?

Nevermind, I figured it out.
Last edited on Dec 23, 2014 at 12:48am
Dec 23, 2014 at 5:33pm
Replace the ";"s with "||" inside the parentheses of your if statement.
Topic archived. No new replies allowed.