Hi,
My code compiles perfectly fine but when i press play unreal engine crashes instantly.The error says that it goes out of bounds but i cant see anywhere that would be out of bounds in my code. It would be very much appreciated if someone could tell me why UE is crashing and how i can fix it.
the error from the crash report i think is:
Assertion failed: (Index >= 0) & (Index < ArrayNum) [File:C:\Program Files\Epic Games\UE_4.24\Engine\Source\Runtime\Core\Public\Containers/Array.h] [Line: 614] Array index out of bounds: 0 from an array of size 0.
my code that i have just added is
int32 Bulls, Cows;
GetBullCows(Guess, Bulls, Cows);
PrintLine(TEXT("You have %i Bulls and %i Cows"), Bulls, Cows);
void UBullCowCartridge::GetBullCows(const FString& Guess, int32& BullCount, int32& CowCount) const
{
BullCount = 0;
CowCount = 0;
for (int32 GuessIndex = 0; GuessIndex < Guess.Len(); GuessIndex++)
{
if (Guess[GuessIndex] == HiddenWord[GuessIndex])
{
BullCount ++;
continue;
}
for (int32 HiddenIndex = 0; HiddenIndex < HiddenWord.Len(); HiddenIndex++)
{
if (Guess[GuessIndex] == HiddenWord[HiddenIndex])
{
CowCount ++;
}
}
}
}
and in BullCowCartridge.h i added this
void GetBullCows(const FString& Guess, int32& BullCount, int32& CowCount) const