Hello Forum,
Inspired by @Zaptruder 's work, I’ve recently implemented some modifications to my own Bull Cow Game.
Using std::cin, my game receives input in the form of a string and through std::stoi converts that string to an integer that is then stored in “GameDifficulty”. You can see the related code below.
However, if the player enters anything other than a numeral such as a character or a symbol, the game crashes with the following error.
So now I’m asking if anyone here can recommend to me a good way to solve this problem and avoid this error? My first idea is to forego std::stoi and instead write an if or a switch statement that will filter out different kinds of entries. I’m hoping that there might be an easier way however.
Cheers.