Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you convert FString into Char* ? UE4

Tags:

game-engine

    const char* bufmessage = PlayerLocation;
    int sendOK = sendto(out, bufmessage, strlen(bufmessage), 0, (sockaddr*)&server, sizeof(server));

no suitable conversion for FString to const char*

like image 500
Drwooi Poipoi Avatar asked Oct 18 '25 16:10

Drwooi Poipoi


1 Answers

A 1 line solution to convert from some FString to char* would be this:

// Assuming you have some FString myFString created e.g., with TEXT("Some FString")
char* result = TCHAR_TO_ANSI(*myFString);

Note: As the comments point out, this assumes the FString will not go out of scope.

like image 99
Ginés Hidalgo Avatar answered Oct 21 '25 04:10

Ginés Hidalgo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!