I'm converting a float to a const wchar_t *
DisplayText(ConversionUtils::FloatToWstring(fps).c_str()); // Prints garbage
DisplayText(std::to_wstring(fps).c_str()); // Doesn't print anything to the device.
with this function :
std::wstring ConversionUtils::FloatToWstring(float value) {
return std::to_wstring(value);
}
I want to get something like that :
DisplayText(ConversionUtils::FloatToConstWcharPtr(fps));
Just return by value:
std::wstring ConversionUtils::FloatToWchar(float value) {
std::string str = std::to_string(value);
return std::wstring(str.begin(), str.end());
}
Or better, use std::to_wstring()
instead.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.