开发者

Convert float to LPCWSTR/LPWSTR

开发者 https://www.devze.com 2022-12-23 07:02 出处:网络
[win 32 C开发者_开发知识库++] I don\'t know how to convert float to LPCWSTR/LPWSTR or LPCWSTR <-> LPWSTR

[win 32 C开发者_开发知识库++]

I don't know how to convert float to LPCWSTR/LPWSTR or LPCWSTR <-> LPWSTR

Thanks a lot


#include <sstream>
...
float f = 45.56;
wstringstream wss;
wss << f;
// wss.str().c_str() returns LPCWSTR
cout << wss.str() << endl;
...


The native Win32 API doesn't have any functions for printing floating point values, but there's a more recent addition called strsafe which has StringCchPrintf

TCHAR buffer[24];
StringCchPrintf(buffer, sizeof(buffer)/sizeof(TCHAR), "%f", float_value);
0

精彩评论

暂无评论...
验证码 换一张
取 消