Guess is undefined

for (int32 PlayerGuessCharacters = 0; PlayerGuessCharacters < HiddenWordLength; PlayerGuessCharacters++)
{
if (Guess[HiddenWordCharacters] == MyHiddenWord[HiddenWordCharacters])

I keep looking at Ben’s code and he hasn’t defined guess in global. I am using VS2017.

Guess is the name of the parameter.

same… need help here too

Can you share your code? :slight_smile:

I am having the exact same error.

there is nothing we can do to help without seeing your code.

Found a solution:
At the very top of the class make sure you put FString Guess, it defines Guess for you. I learned this by simply moving on with the error only later to realize there was a solution.

FBullWomanCount FBullAndWomanGame::SubmitGuess (FString Guess)
{
//CAUTIONL WILLCRASH IF ANSWER ISLESS THAN HIDDEN_WORDl length
//increment turn number
MyCurrentTry++;
//setup return variable
FBullWomanCount BullWomanCount;
//loop thru all letters in guess
int32 HiddenWordLength = MyHiddenWord.length();
for (int32 HWChar = 0; HWChar < HiddenWordLength; HWChar++) {
// compare letters against the hidden word
for (int32 HWGuess = 0; HWGuess < HiddenWordLength; HWGuess++) {
// if they match then
if (Guess[HWGuess] == MyHiddenWord[HWChar]) {
if (HWChar == HWGuess) { // if they’re in the same place
BullWomanCount.Bulls++; // incriment bulls
}
else {
BullWomanCount.Woman++; // must be a cow
}
}
}
}
return BullWomanCount;
}

Privacy & Terms