Do you need to dereference the Words Array?

Hello there,
For this challenge I did the following PrintLine in my for loop;

PrintLine(Words[i]);

And the words printed as expected. I did think about putting the TEXT macro in but I thought that as they are stored using the TEXT macro that would carry forward.

So the question is do we have to deference in this particular instance? Or are you just drumming it in so to speak to always as good practise deference?

Many Thanks

That is because PrintLine works with passing a single FString.

I think you misunderstand what the macro does. The macro just adds a prefix or nothing at all. It’s needed to turn a string literal into the correct string literal type for the targeted platform as Unreal uses Unicode and different platforms use different character types to store Unicode Code Points.

FString stores a TArray<TCHAR> where TCHAR is the correct character type for the targeted platform. For Windows that’s wchar_t, others might use char or char16_t.

"Hello"

Is of type const char[6]

L"Hello"

is of type const wchar_t[6]. That is what the TEXT macro does on Windows, it prepends an L. On different platforms it might prepend u or do nothing at all. But it’ll be correct whatever the platform is being compiled for.

No because of the first point. FString is only needed to be dereferenced to get a const TCHAR* which is needed for Printf

Thanks Dan :slight_smile:

1 Like

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