I'm encountering a problem in my code. Here, the turn() function returns a boolean depending on whether the player has won this turn or not, and the variable "lifes" counts the number of remaining lives of the player. When the condition is no longer met, the loop ends and the problem occurs :
- If lives>0 (and turn()==false), I get "In" and the loop continues. This is expected. (The case where lives==0 and turn()==true never happens).
- If lives>0 (and turn()==true), I get "Win" and the program continues. This is also expected.
- If lives==0 (and turn()==false), I get "In" because the loop continues, and the whole program stops right after. I can't understand why the loop doesn't stop and the rest of the program is not executed normally.
while (!lives ^ !turn(word, lives, guessed, said))
{
cout << "In" << endl;
}
cout << "Out" << endl;
Aucun commentaire:
Enregistrer un commentaire