Given an FString of "123.2222,446.4444,55234.2342" how do you convert this to a TArray of type uint16?
Current attempt is to parse the string into an array using
TArray<FString> Parsed;
HeightMapData.ParseIntoArray(Parsed, TEXT(","), false);
This seems to work well. Next is the problem of how do I convert this to uint16.
I am trying
const TArray<uint16*>& parsedArray = reinterpret_cast<const TArray<uint16*>&>(Parsed);
But it is not working. Error: Parent address is invalid for parsedArray
CodePudding user response:
You can't reinterpret_cast
and pretend your array of strings is an array of integers. You need to convert each string to an integer in a new array:
TArray<uint16> intArray;
for (const auto& str : Parsed)
intArray.Add(FCString::Atoi(str));