[英]c++ float to const wchar_t* converting function
我正在將浮點數轉換為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.
具有此功能:
std::wstring ConversionUtils::FloatToWstring(float value) {
return std::to_wstring(value);
}
我想得到這樣的東西:
DisplayText(ConversionUtils::FloatToConstWcharPtr(fps));
只需按值返回:
std::wstring ConversionUtils::FloatToWchar(float value) {
std::string str = std::to_string(value);
return std::wstring(str.begin(), str.end());
}
或更好,使用std::to_wstring()
代替。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.