My program always returns a value of 0 for Bulls and Cows respectively

Hi guys,

So at the end of lecture 36, Ben runs his program and gets positive values for his Bulls and Cows variables. However, when I run my program, they are always both 0 each.

I cannot see any errors in my code when compared to Ben’s.

Any help would be appreciated.

1 Like

Hi Gerald
I am having the same problem.
A little bit frustating. This get me nervous.

Did you get any responses for this problem?

Hi Ben and Co.
Any ideas for this behavior?
Getting nervous for not being able to find the solution.
Revised my 3 codes some times… found nothing wrong.
Probably the mistake is in my face.
Gettint to lesson 36 was not easy.
Many hours dedicated to this course.
Thanks a lot for any help.

What you are showing has only the same bug he had (and fixed).

I got into a habit of adding std::cout statements into sections of my code to error check myself as I go along to make sure things are working - in lieu of the debugger.

Underneath the BullCount.Bulls++; and BullCount.Cows++ add in std::cout << “Adding a Bull to the count.” << std::endl; (and have the other say adding a cow). Then just above the return statement add in another cout to say something like “Returning " << BullCount.Bulls << " Bulls & " << BullCount.Cows << " Cows.” << std::endl;

If those show correctly, you know the problem lies outside of that function. You can delete any added lines later to clean it up. Let me know what you come up with.

Having the same issue here…

I’ve gone in and added some cout-s to see what the for loops are creating but I’m not getting anything inside the for loops…

Outside of the for loop however,
I found that MyHiddenWordLength is returning 0. So there must be an issue there. Going to try and figure that out.

found that the hidden word and length are able to print out in the Reset function so that is functional but it won’t for some reason let me use it in another function.

Okay went through and added cout-s to find where my issue was… at some point it just worked… not sure why really… i rebuilt several times before it started working so I’m going to remove cout-s now and see what happens… maybe it’ll break again…

ugh… well… hate to say this but seriously couldn’t find the issue even after taking all the cout-s out… so… may have to chalk this up to fluke…

guys what is your hidden word ?

so i was having the same problem and after thoroughly looking into my code, I found that inside
void FBullCowGame::Reset()
i was not initializing my private member (MyHiddenWord) . Rather I did this

const FString Hidden_word = “ant”;
FString My_Hidden_Word = Hidden_word;

I just changed the above lines with

const FString Hidden_word = “ant”;
MyHiddenWord = Hidden_word;

Now its working fine.

1 Like

I am facing the same problem with my code and don’t seem to find any solution for the same. any sort of help would be appreciated!

Privacy & Terms