Unreal Crashes due to if(!IsIsogram) function

https://pastebin.com/Lr30cbBy
i have included the pastebin link. unless the comment out the if(!IsIsogram(Guess)) function(Line 48) the unreal editor crashes as soon as i press enter in the terminal. i don’t understand why this is happening.

Another far less troublesome issue i am facing is if i declare a function in say a for loop
for(int32 integer;integer<maxvalue;integer++)
i get an error saying integer is undeclared.

I think your isisogram returns true as soon as the first Word[Index]==Word[Comparison] doesn’t match instead of iterating over the rest of the characters, because you return if it’s not a match on the first check.
So ANY word with differing first two characters returns true.

As to for loops, pretty sure if you declare the iterator in a for loop you have to assign it a value. Otherwise, declare it outside the loop.

for (int32 integer = 0; integer < maxvalue; integer++) …
OR
int32 integer = 0;
for (integer; integer<maxvalue; integer++) …

i understand i made an mistake in my code. but that doesn’t explain the crashing. fixing the code didn’t help either.

the editor didn’t recognise the integer even when i assigned a value in the for loop. for me it only works if i declare the integer outside the loop

What’s the actual error in the crash screen?

this is whats written in the unreal crash reporter
https://pastebin.com/3pwzZxrZ
this is text copied from the crash log
https://pastebin.com/L9uxUjJt

It’s an index out of bounds, in the Word[Index] == Word[Comparison] check (log indicates line 103, so just before that is the comparison). The for loop starts with Comparison as 1. Somehow you’re getting to Comparison of 5 when you iterate the guess check, in that check (assume your guess is 5 characters). Whereas an array can only go to one less than the string length. For a 5 character word, the first character is referenced with Word[0], the last with Word[4] before you go OUT OF BOUNDS and generate a run-time crash. You might need to limit that <Word.Len() to <Word.Len-1 for the comparison value… to keep it from crashing OR adjust how you index things to more safely check the array.

You’re calling IsIsogram before the checks of the length. The IsIsogram function only works when the Guess and HiddenWord are the same length.


On a side note please format your code. I had to run your code through a formatter in order to read it as it was impossible to read.

After fiddling with it a bit i decided to go through the archived version of bullcow and afterwards try rewriting the code from scratch. In the end i ended up copying the entire code from the latest lecture.Somehow i seemed to have broken the terminal and it doesn’t seem to be doing anything.

At this point i don’t know if i am being a complete idiot or the software are being weird. I think i will finish the course and read a book before coming back to this again.
But thanks for the help on what may or may not be a lost cause

Would need to see your new code and crash log to help further when you are ready to get back to it.

Privacy & Terms