Crash Error ? can some one solve this

Here is the My cpp file.

// Fill out your copyright notice in the Description page of Project Settings.
#include "BullCowCartridge.h"
#include "HiddenWordList.txt"
#include "Misc/FileHelper.h"
#include "Misc/Paths.h"
void UBullCowCartridge::BeginPlay() // When the game starts
{
    Super::BeginPlay();
    const FString WordListPath = FPaths::ProjectContentDir() / TEXT("WordList/HiddenWordList.txt");
    //FFileHelper::LoadFileToStringArrayWithPredicate(UList, *WordListPath, [this](const auto& word) {return Isogram.Num() && word.Len() <= 8 && word.Len() >= 4; });
    Isogram = Justifiable(UList);
    Justifiable(UList);
    DefineOrgenization();//declard first function
}

void UBullCowCartridge::OnInput(const FString& Input) // When the player hits enter
{
   if (ClearGamble) //declard the function under to the if statement
   {
       ClearScreen();//for clearscreen
       DefineOrgenization();//for further approch
   }
   else//declard function under to the else statement 
   {
       DefineApproach(Input);//declard approch Function
   } 
}
void UBullCowCartridge::DefineOrgenization()
{
    PrintLine(TEXT("Appreciate To Appear as an Player"));
    Unseen = Isogram[FMath::RandRange(0, Isogram.Num() - 1)];
    Lives = Unseen.Len();//Set the Lives = Unseen 
    ClearGamble = false;//set bool as an false value

    PrintLine(TEXT("It's your Lives :%i "), Lives);
    PrintLine(TEXT("The Unseen Word Is :%s"), *Unseen);//Debug Line
    PrintLine(TEXT("Press The Enter for Resume"));
}
void UBullCowCartridge::DefineConclusion()
{
    ClearGamble = true; //declard true bool value
    
    PrintLine(TEXT("Press Enter To Play Again "));//to print in the end
}
void UBullCowCartridge::DefineApproach(const FString& Imagine)
{
    if (Imagine == Unseen)  //check the correct word if it s tue than go further if it's not than play agian or exit
    {
        ClearScreen();//for clarscreen if one can won
        PrintLine(TEXT("You are Secure"));
        DefineConclusion();//to the play again
        DefineOrgenization();//to the welocme player
        return;
    }
    else
    {
        if (Imagine.Len() != Unseen.Len()) //check the lives and hiddenword
        {
            PrintLine(TEXT("Your Current Lives Is : %i"), Lives);
            PrintLine(TEXT("The Unseen Word Is : %s"), *Unseen);
            DefineConclusion();
            return;
        }
        if (!ISarithm(Imagine)) //check the repiting words
        {
            PrintLine(TEXT("No Repeting Words"));
            PrintLine(TEXT("Your Remaning Lives Is : %i"), Lives);
            return;
        }
        PrintLine(TEXT("Don't Loose Hope"));
        --Lives;
        if (Lives <= 0) //if Lives is zero
        {
            ClearScreen();
            PrintLine(TEXT("You Don't Have Any Lives"));
            PrintLine(TEXT("You Loose"));
            DefineConclusion();
            DefineOrgenization();
            return;
        }
        PrintLine(TEXT("Game Over"));
    }       
}
bool UBullCowCartridge::ISarithm(const FString& word)
{
    for (int32 Clue = 0; Clue < word.Len();Clue++)//comparision the words
    {
        for (int32 Comparision = Clue + 1 ; Comparision < word.Len(); Clue++)
        {
            if (word[Clue] == word[Comparision])
            {
                return false;
            }
        }
    }
    return true;
}
TArray<FString> UBullCowCartridge::Justifiable(const TArray<FString>& UUList)
{
    TArray<FString> VaildWords;
    for (FString Tword : UUList) //comparision of another unseen words
    {
        if (UUList.Num() <= 8 && UUList.Num() >=4 && ISarithm(Tword))
        {   
            VaildWords.Emplace(Tword);
        }  
    } 
    return VaildWords;
}

It’s saying you are going out of bounds here. In other words Isogram is empty. What’s UList?

UnseenList

where is the error?

But where is it defined? What does it store?

Right here Isogram[.... If Isogram is empty (which the crash log says it is) then accessing any index here would crash as you are out of bounds as there’s nothing in the array.

so what do i do ?

Answer the question as I’m trying to help you find out why it’s empty. So, where did you define UList?

the hiddenword.h file
there i define this thing

I was asking you to show it but I think I found the problem.

sir can you tell me one thing please?

I don’t understand.


Again Error !

If all you did is uncomment that line, then that’s expected. Your use of LoadFileToStringArray is incorrect. I suggest you re-read the article.

Did you fix the code I pointed out?

yes sir as you said

Did you successfully compile that though?

yes sir

Well I’m blind. This is checking the arrays size and not the word.

Privacy & Terms