正如标题所示,我想知道将 int
转换为 const wchar_t*
的最佳方法。
其实我想用_tcscpy
函数
_tcscpy(m_reportFileName, myIntValue);
最佳答案
由于您使用的是 C 方法(我假设 m_reportFileName
是 raw C wchar_t
数组),您可能只想直接考虑 swprintf_s()
:
#include <stdio.h> // for swprintf_s, wprintf
int main()
{
int myIntValue = 20;
wchar_t m_reportFileName[256];
swprintf_s(m_reportFileName, L"%d", myIntValue);
wprintf(L"%s\n", m_reportFileName);
}
在更现代的 C++ 方法 中,您可以考虑使用 std::wstring
代替原始 wchar_t
数组和 std::to_wstring
用于转换。
关于c++ - 将 int 转换为 const wchar_t*,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15109469/