If (Guess[j] == MyHiddenWord[i]) | expected and expression (vid 40)

Got the above error when doing video 40. Also the debugger takes me to:

‘xstring’ line 2944 ‘_IDL_VERIFY(_Off <= this->_Mysize(), “string subscript out of range”);’

and says “Exception Thrown: BullCowGame.exe has triggered a breakpoint”

VS2017 then crashes when I try to use their tools to get more information.

I don’t receive my error messages.

What could be the problem.


FBullCowCount FBullCowGame::SubmitGuess(FString Guess)
{
	// recieives a valid guess, increments turn and returns count.
	MyCurrentTry++;
	//setup a return variable.
	FBullCowCount BullCowCount;
	//loop through all letters in the guess.
	int32 HiddenWordLength = MyHiddenWord.length();
	//compare letters against the hidden word
	for (int32 i/*MyHiddenWordChar*/ = 0; i < HiddenWordLength; i++)
	{
		for (int32 j/*GuessChar*/ = 0; j < HiddenWordLength; j++)
		{
			//if they match
			if (Guess[j] == MyHiddenWord[i])
			{
				if (i == j)//if they are in the same place
				{
					BullCowCount.Bulls++; //increment bulls
				}
				else
				{
					BullCowCount.Cows++; //increment cows
				}
			}
		}
	}
		
	return BullCowCount;
};
1 Like

Hi, that code has a small bug that triggers the crash error, it has been answered here multiple times
e.g. see one of my previous answers to this problem:

2 Likes

Hello dear @Justin_Jahn,

@ben mentioned this problem in the earlier videos. Additionally, he said that this will be fixed in further videos.

Kind regards
Kevin

1 Like

Privacy & Terms