Bulls & Cows, Lives keeps decrementing below 0

Hello there, i have tried to fix this but i do not know where the problem is, okay so, the problem is even though i did not set Lives to decrement in the (Guess.Len() != HiddenWord.Len()) part, still, it decrements the Lives until below zero and it won’t run the EndGame() function like the screenshot i took in UE4, but when i input a word that has the same amount of characters, it ends the program and that’s the behavior that i wanted, can someone help me where the problem is?:slight_smile:

I am so so sorry i made this question a bit long… hehe xD
oh yeah, and this happened after the Const Member Functions lecture.

Can you share your full .cpp and .h code?

1 Like

You have --lives and if lives <= 0. So if your code runs again after --lives hits 0 then you get --lives becoming -1. You would have to end the game on 0.

I’m guessing that your EndGame() isn’t actually ending the game. There’s possible other reasons such as if you have --lives somewhere else.

1 Like

Ohh okay, thank you for the information!

i’ve fixed it, but thankyou so much for being considerate :grinning_face_with_smiling_eyes:

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms