How can I output a String char by char?

Hi, i want to know how can i draw using canvas or using Debug Message to show a String line char by char.

I know how can i get it using GetCharArray() or using Text[0] but i dont know how to print it because i dont know how to cast TCHAR to FString

Thanks

FString output = “SomeString”;
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, *(output));

That gives a debug message of a string. You can attach ints to the string as well or append chars.

“because i dont know how to cast TCHAR to FString”

#Converting a single TCHAR to FStirng

Here’s how I’ve succesfully converting a single TCHAR to an FString

FString MyChar("" + 'c');

do this in a loop if you really want FStrings for each char of an original FString.

however,

#Most Functions what TCHAR* , not FString


#UE LOG

TCHAR c = 'c';
UE_LOG(SolusLog,Warning,TEXT("Single Char: %s"), c);

#OnScreenMessage

    TCHAR c = 'c'; 
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("%s"), c));

:heart:

I think FString constructor accept TCHAR, fstring(“something”)

#I forgot the FPrintf

Sorry, this will work now!

TCHAR c = 'c'; 
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("%s"), c));

OnScreenMessage just supports FString, and if i do this FString MyChar("" + ‘c’);, shows an n instead of a c.

Just i want to do its this

FString Hi = “Hi there”;
TArray t = Hi.GetCharArray();
for (int i = 0; i < t.Num(); i++)
{
TCHAR c = t[i];
// Here prints the char on screen
}

This just show on screen SomeString, that i want to do its show a char of the String (for example if i want to print the ‘e’ , its the 4 position of the string

Thanks dude, it works!!! I dont knot that its possible to use Printf hehe

But there is a little mistake, you are using %s , that is for print strings, and we are using a type of char so it should bt %c instead

#Resolved

Great!

I am glad you got this figured out now! I will remember %c for the future :slight_smile:

(if you can, check mark my answer this post if your issue is resolved)

FString is basically a character array anyway. You could always:

FString theString = "SomeString";
FString output;
output.AppendChar(theString[3]);
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, *output);