你可以使用什么来将int/float转换为wchar_t*?

Mar*_*ark 1 c++

如果你有一个int或者float,你如何在wchar_t*不使用像boost这样的外部库的情况下将其投射到一个?

Own*_*loo 5

std::wostringstream oss;
int i = 1212;  // or float f = 1212.0f;
oss<<i;        // oss<<f;

std::wstring ws = oss.str();
const wchar_t* cwp = ws.c_str(); // const wchar_t*

std::vector<wchar_t> buf( cwp , cwp + (wc.size() + 1) );
wchar_t* wp = &buf[0];  // wchar_t*
Run Code Online (Sandbox Code Playgroud)