The * in format specifiers

hey,
I didn’t really get when do I need to use the * for format specifiers.
Can you please help me?

It’s specifically for FString's

The UE_LOG macro (shown later) and PrintLine both use FString::Printf which uses one of the printf family of functions from the C standard library under the hood.

Those functions only know about builtin types that come with the C language, int, float, double, char, bool. None of which are FString as that’s a user defined type created by Epic.

FString stores a null terminated sequence of characters. i.e.all characters are next to each other in memory and the last character ends is '\0' e.g. "h e l l o \0"

This is how C deals with strings. C functions take a pointer to the first character and it reads characters until it reaches the null character and then stops.

This is what FString::operator* does, if the string is not empty it returns the pointer to the first character otherwise it returns and empty string literal "".

Further reading on C-style strings:
https://www.learncpp.com/cpp-tutorial/66-c-style-strings/

thank you

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

Privacy & Terms