+ 1

Console game problem | C++

I just started making a console game, and I've come to an if-statement where it doesn't work as I want it to do: This is my code for the if-statements: https://gyazo.com/e3e08caf4400e3c05ed8b64120dd14fe When I say "drive by" to the question: https://gyazo.com/85c330f950f2159d668aaa8b17e445b9 https://gyazo.com/3108762c8ed37321098862e0c74c418b As you can see, it acts like a said "talk" but I didn't, and I don't know why it doesn't skip the if statement, and goes to the else if instead. Please help, I can't continue my game, until this is fixed. It tears me apart.

23rd Mar 2017, 2:35 PM
Søren
4 odpowiedzi
+ 2
if(Q[5] == "Talk" || "talk") isn't going to work, "talk" will evaluate to true. Use if(Q[5] == "Talk" || Q[5] == "talk"), same thing with your other ifs.
23rd Mar 2017, 3:35 PM
Dennis
Dennis - avatar
+ 1
Are you reading to Q[5]? where are the statements that accepted the input? Also, you may want to clear Q[5] before reading to it, to rule out any prior junk in it.
23rd Mar 2017, 2:57 PM
Eddie Perez
Eddie Perez - avatar
+ 1
@dennis you'are right I didn't see that one
23rd Mar 2017, 3:46 PM
Eddie Perez
Eddie Perez - avatar
0
Thank you, very much @Dennis.
24th Mar 2017, 10:18 AM
Søren