Fun little error

I know you guys have a word list of 1000(+) words, but if you had a list of only 3 words and the program tries to check the 4th word…
Add a check to make sure Index is less than the Words.Num() if you don’t want Unreal Engine to die. :sweat_smile:

like so:
for (int32 Index = 0; Index !=10 && Index < Words.Num(); Index++)
{…}

for (int32 Index = 0; Index !=10 && Index < Words.Num(); Index++)
{…}

Index !=10 && is unnecessary because if you have 4 words in list Words.Num() will be 4.
Keep in mind first word in the list is of an index 0.
e.g. beg, love, hate, mercy
0 1 2 3

Index < Words.Num() this will run until Index is 4 and when the Index is 4 condition is false and block of code won’t be executed. So it will never look for 5th word of an index 4 in the word list where Words.Num() equals 4 and cause Unreal Engine to crash.

Privacy & Terms