Help! On Lecture 42 (Won't read Bulls and Cows on my Guesses anymore)

Hello,

I can’t seem to get my program to read the Bulls and Cows on my Guesses anymore; right after the do and while code was inputted to address the errors in the program. Please see attached image.

or perhaps it’s in my main.cpp on printing my Bulls and Cows code?

and this is my Bulls and Cows counter in FBullCowGame.cpp:

Any advice would be appreciated. thanks!

Hi there Lionel,

Can you elaborate on your first picture a bit? Specifically the picture of your terminal output. It looks like if you type in a 6 letter word and hit enter, it just repeats the line “Try 1. Enter your guess:”

Is this correct?

Additionally, here’s something to try out:

print something simple, like hello1 and hello2, right around where the print of bulls and cows takes place. More specifically, place:

std::cout << "hello1" << std::endl;

above

std::cout << "Bulls= " << BullCowCount.Bulls;

and

std::cout << "hello2" << std::endl;

below

std::cout << "Cows= " << BullCowCount.Cows;

in main.cpp.

This is to ensure that, when executing, your code there is at least being executed. If you see “hello1” and “hello2” being printed, you know that there’s some problem with your print statements. If you only see hello1 printed, then the code below it likely isn’t even being executed. If you see neither hello1 nor hello2, then execution might not be making it out of the function call
BCGame.SubmitValidGuess(Guess)
at all. If you see the last case, you might have an infinite loop or something weird going on within SubmitValidGuess

Alright thank you. I will try that on when i get back on my laptop tonight.
Thank you for the quick response.

I’m really quite new to this and its being quite complex for me as the
course goes along. :slight_smile:

Yes, that is correct. My hidden word is a 6 letter word.

No problem! Hope I can help get to the bottom of the issue.

Check back in once you get the results of that test.

It’s still not printing. even the hello1 and hello2 isn’t printing. I think there is something wrong with my loop…

any advice? =)

So visual studio has several tools for debugging that can be really helpful. If you’re feeling adventurous, go look up info on visual studio’s debugger and its process.

BUT, that might be a little overwhelming if you’re just starting to learn how to code. So my advice is to find the latest possible point in your code that still prints. In general, this is a good strategy to really narrow the possible bug locations in your code. When I was a student, utilizing print statements in this was were my goto debugging method. I recommend getting handy with that. Then, when you’re feeling relatively comfortable with visual studio, go out and learn how to use its native debugger.

So anyway, go snoop around with those print statements and feel free to post any updates or questions here. I’ll check this thread periodically.

1 Like

Alright, sure. Thanks for the advice. =) I’ll see if i can get this bug fixed. Will get back to you when i find something. Cheers!

Your problem should be inside GetValidGuess

OldDauber
Your problem should be inside GetValidGuess

Ok thank u for the tip . :slight_smile:

Hi,

So I think the problem here was that before i placed:

while (Status =! EGuessStatus::OK); //keep looping until we get no errors.

So i was looping since it was always not equal to OK… but now i got back to my original problem in which i’m getting an error in inputting a word with less than or equal to 4 letters only (please see attached image)… in which i thought this was supposed to be fixed already by now?

Please correct me if I’m wrong here. Any advice?

Thank you.

and am i not supposed to win the game and the game ask if i already want to play again if i get the guess right, when i got the right answer the first try?

The Debug Assertion Failed error you’re getting is well known here (and if I’m not mistaken the instructor covers it in one of the next videos), Anyways, see one of my previous replies on how to fix it:

POST NOTE: Omg i think i found the problem, all these time my

else if (false //return ok
{
return EGuessStatus::OK;
}
}

it was endlessly looping because i should’ve set it to TRUE.
i think i solved the problem.fyi =)

((THE MESSAGE BELOW WAS BEFORE I FIGURED OUT THE SOLUTION))
I’m stuck now and i cant seem to move forward.

It’s a matter of transferring my return Guess, and suddenly my program isn’t working right…

Please see attached:

program still works here, if i type in the correct word it print Bulls and Cows count:

but when i transfer it below in the while loop, my program can’t print Bulls and Cows count anymore, but goes on in endless loop:

I think upon investigation i think my While loop isn’t working… i really don’t know why though…

Sorry if I’m such bad at this, but i really don’t know how to fix it… =(

Sorry, was gone and off the grid for a few days at a wedding. Glad you figured it out! Take note of some of the debugging methods you used and we suggested. Those will come in handy in the future :wink:

Alright well noted. Thank you. I might messae from time to time if u get
more concerns. Thank u

Privacy & Terms