Bool function won't work. Can't figure out why?

...
Last edited on
I'm guessing it's because you tried to divide by 0. Look closely at lines 72, 79, 86, etc. Then look at lines 35 to 40.
I took a look and I don't think those are the problem. The game works on a loops like its supposed too but when the user presses 'q' to end the program/game and bring up the results (which are supposed to print from the bool, it wont. It doesn't return the true/false value of the bool either.
Result == 't';

This is a comparison operation. You're checking if the value in Result is equal to 't'. So in your rps function, you are not actually changing the value of Result at all. It is still whatever garbage value it was when the program was started (since the variable wasn't initialized).

1
2
3
4
5
6
if (Game_Result == 'w')
    Win_Count++;
else if (Game_Result == 'l')
    Loss_Count++;
else if (Game_Result == 't')
    Tie_Count++;


Here you try to check the value of Game_Result. But as I said, it's a garbage value, very unlikely to be any one of 'w', 'l', or 't'. So in all probability, Win_Count, Loss_Count, and Tie_Count all stay at 0.

double Perc_Wins = (Wins / (Wins + Losses + Ties) * 100);

Here you try to do math with those values. You are trying to compute 0 / (0 + 0 + 0) * 100. The program crashes since you are trying to divide by 0.
Last edited on
Fixed and running flawlessly! Thanks again fg109! All I had to do was remove the extra '='s in the rps function and it changed the values and I was good to go!
Last edited on
Topic archived. No new replies allowed.