Getting error C2338 and C4840

I tried making the array a txt in order to reduce the compiling time, but obviously I’ve done something wrong and I’m not really sure. Through commenting out various line, I’ve figured out that it probably has to to do with how I wrote it in the header.

Please help

My BeginGame()

void UBullCowCartridge::BeginPlay() // When the game starts
{
    Super::BeginPlay();
    const FString WordListPath = FPaths::ProjectContentDir() / TEXT("WordLists/HiddenWordList.txt");
    FFileHelper::LoadFileToStringArray(HiddenWords, *WordListPath);
    //HiddenWords.RemoveAll([this](auto& word) {return IsIsogram(word); });
    SetupGame();

    PrintLine(TEXT("The number of possible words is %i"), HiddenWords.Num());
    PrintLine(TEXT("The Hidden Word is: %s."), *HiddenWord);//Debug Line
    
    for (int32 Index = 0; Index < 5; Index++)
    {
        PrintLine(TEXT("%s"), HiddenWords[Index]);
    }
    
}

My header file

#pragma once

#include "CoreMinimal.h"
#include "Console/Cartridge.h"
#include "BullCowCartridge.generated.h"

UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
class BULLCOWGAME_API UBullCowCartridge : public UCartridge
{
	GENERATED_BODY()

	public:
	virtual void BeginPlay() override;
	virtual void OnInput(const FString& Input) override;
	void SetupGame();
	void EndGame();
	void ProcessGuess(FString Guess);
	bool IsIsogram(FString Word) const;
	TArray<FString> HiddenWords;


	// Your declarations go below!
	private:
	FString HiddenWord;
	int32 Lives;
	bool bGameOver;
};

This is missing *.

1 Like

Thank you, that did the trick.
Could you explain what the * actually does in the context?
I’m not really understanding that part.
Thanks in advance

For an FString it gets the underlying character array. It’s defined as

const TCHAR* FString::operator*() const
{
    return Data.Num() ? Data.GetData() : TEXT("");
}

Where Data is TArray<TCHAR> and GetData returns a pointer to the first element. It’s a way to get a “c-style” string from FString.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms