你可以使用什么来将int / float转换为wchar_t *? [英] What can you use to cast an int/float to a wchar_t*?
本文介绍了你可以使用什么来将int / float转换为wchar_t *?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果您有 int
或 float
,如何将它转换为
If you have an int
or float
, how can you cast it to a wchar_t*
without using external libraries like boost?
推荐答案
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*
这篇关于你可以使用什么来将int / float转换为wchar_t *?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文