如何获取LPCWSTR
类型变量的字符串表示形式(UINT
)?
答案 0 :(得分:4)
LPCWSTR
是常量LPWSTR
,它是指向宽字符串的指针。您应该使用std::wstringstream
:
#include <sstream>
// ...
UINT number = 42;
std::wstringstream wss;
std::wstring str;
wss << number;
wss >> str;
LPCWSTR result = str.c_str();
答案 1 :(得分:1)
试试_itow。它采用无符号整数,宽字符缓冲区的地址以及用于转换的基数。
以下是一个例子:
UINT x = 1000245;
LPWSTR y = (LPWSTR)malloc(30);
_itow(x, y, 10);