Game is now broken, compiles fine but I get the following error when entering any guess:
FYI This is using the exact copy commit as per :: https://github.com/UnrealCourse/02_BullCowGame/tree/69fb2728d0c8fdab1fc921169129f7fe58d97e58
ERROR: Expression: string subscript out of range
When i comment out the below section things work, so far even putting a break point in has not helped. I am at a loss as to what is exactly happening here? Is it out of bounds? I could nail it to this line –
if (Guess[GChar] == MyHiddenWord[MHWChar])
when you call that i get the error…
int32 HiddenWordLength = MyHiddenWord.length();
for (int MHWChar = 0; MHWChar < HiddenWordLength - 1; MHWChar++) {
// compare letters against the hidden word
for (int GChar = 0; GChar < HiddenWordLength; GChar++) {
// if they match then
if (Guess[GChar] == MyHiddenWord[MHWChar]) {
if (GChar == MHWChar) { // if they're in the same place
BullCowCount.Bulls++; // incriment bulls
}
else {
BullCowCount.Cows++; // must be a cow
}
}
}
}
EDIT: And the weird bit is I had this working until we fixed the error in Debugging 101
Further EDIT: The error goes away if I enter the same number of characters as the wordlength. So if the hiddenword is “planet” and I enter another word that has 6 characters the program does not break. Getting somewhere with this, would really appreciate the help tho.