Unreal Engine 5 · Blueprint → C++
Format String (Printf) in Unreal Engine 5 C++UE Docs
The Blueprint Format String node maps to FString::Printf in Unreal Engine 5 C++, which builds a formatted FString using printf-style specifiers like %s and %d.
Blueprint node & C++ equivalent
FString S = FString::Printf(TEXT("Player %s scored %d"), *PlayerName, Score);The C++ equivalent of Format String
FString::Printf(TEXT("Player %s scored %d"), *PlayerName, Score) formats a string using classic printf specifiers. %s inserts a string, %d inserts an integer, and %f inserts a float. The format literal is wrapped in TEXT() because Printf expects a TCHAR format string.
Why dereference with the asterisk
Note the *PlayerName in the arguments. FString does not pass directly to a %s specifier; the * operator returns the underlying const TCHAR* buffer that printf needs. Forgetting the dereference is the single most common cause of garbage output or crashes when using FString::Printf.
When to use it
Use FString::Printf for debug logging, on-screen messages, and any runtime string that does not need localization. For user-facing, translatable text, prefer FText::Format instead so your strings can be localized.
Frequently asked questions
How do you format a string in Unreal Engine 5 C++?+
Call FString::Printf(TEXT("..."), args...) with printf-style specifiers. For example FString::Printf(TEXT("HP: %d"), Health) builds a formatted FString.
Why do I need the asterisk before an FString in Printf?+
The %s specifier expects a const TCHAR*, not an FString. The * operator on an FString returns that raw character pointer, so *PlayerName passes the correct type.
Is FString::Printf good for localized text?+
No. FString::Printf produces a non-localized FString. Use FText::Format with NSLOCTEXT or LOCTEXT for user-facing text that needs translation.