Game crashes after moving "return Guess;" into default action of switch function

Expected behaviour :
If the word lenght is correct print back the number of cows and bulls

Observed behaviour :
If the word lenght is wrong it says Please enter “” letter word.
If the world lenght is correct the game crashes

Tried solutions:
move return Guess out of switch function - counts bulls and cows even if the word length is wrong
run debugg while the return Guess is in switch and this happenes

It’s impossible to tell from your screen shot how to solve the problem. A bad_alloc generally means your program tried to allocate memory and failed to do so. An exception was thrown and you didn’t have any code written to handle the exception, hence your program crashed.
Exception handling is beyond the scope of what we’ve been learning here so far. The easiest thing to do in this situation would probably take a look at Ben’s code on Github and compare it with your own. You should be able to find the commit which corresponds with where you’re up to and see what you did differently.

After changes in the next video it started to work properly … someday a may know what was wrong :smile:

Privacy & Terms