I must say this is not quite the correct solution. This code only works when the hidden word and the guessed word have the same length, otherwise it may or may not cause an issue. e.g. it will cause an assertion failure when your hidden word has 5 letters and you try a guess with a 3-letter word.
The problem is this code assumes that Guess.length() == MyHiddenWord.length() always! So instead of using MyHiddenWordLength in both for loops, you use Guess.length() in the first loop, and as a result use the appropriate index (j) for the MyHiddenWord. See this corrected version:
FBullCowCount FBullCowGame::SubmitGuess(FString Guess)
{
//increment turn number
MyCurrentTry++;
//setup a return variable
FBullCowCount BullCowCount;
int32 HiddenWordLength = MyHiddenWord.length();
for (int32 i = 0; i < Guess.length(); i++)
{
for (int32 j = 0; j <= HiddenWordLength - 1; j++)
{
if (TheGuess[i] == MyHiddenWord[j])
{
if (i == j)
{
BULL_COW_COUNT.Bulls++;
}
else
{
BULL_COW_COUNT.Cows++;
}
}
}
return BULL_COW_COUNT;
}
}