This is the function I wrote.
If the Input is “hell” the function returns false, as expected.
if the Input is “hello” the function returns true, this is not ideal.
I presume the problem is somewhere betweenthe position [2] and [3].
I wrote the code myself then compared to the one written by Mike. It’s practically the same if I’m not mistaken.
What is the problem?
bool UBullCowCartridge::IsIsogram(FString Word) const {
int32 Index;
int32 Compare;
for (Index = 0; Index < Word.Len(); Index++)
{
for (Compare = Index + 1; Compare < Word.Len(); Compare++)
{
if (Word[Index] == Word[Compare])
{
PrintLine(TEXT("false")); //debug line
return false;
}
}
}
return true;
}