To many Arguments for function-like marco Invocation 'TEXT'

I have followed the code as shown in the Unreal Engine and C++ course and ran into an error in the compile logs for UE4. It’s throwing the error of: “[2022.02.09-00.33.06:547][411]CompilerResultsLog: F:\Audio and Video MEDIA projects\Unreal Engine Udemy course resources and downloads\Unreal Course downloads\BullCowGame-starter-kit\Source\BullCowGame\BullCowCartridge.cpp(36) : error C4002: too many arguments for function-like macro invocation ‘TEXT’”

My code looks like this:

What am I to do?

If I remember right, you have to use FString::Printf in the lines with variables/functions. So for example your

PrintLine(TEXT("Guess the %i letter word"), HiddenWord.Len());

should be like this

PrintLine(FString::Printf(TEXT("Guess the %i letter word"), HiddenWord.Len()));

same for the "The hidden word is %i character…

But I am pretty sure is because you forgot the () at HiddenWord.Len() in the last line I pointed.

Well, I asked about this same issue in the Unreal Engine forums, and someone suggested I needed to write it like this.

PrintLine(TEXT("The Hidden Word is %i characters long, try again!"), HiddenWord.Len());

Which is closer to the example videos I’ve been following, so are they both correct?

Yes. PrintLine is using FString::Printf internally.

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