As the title indicates I want to know the best way to convert an int to a const wchar_t*.
in fact I want to use the _tcscpy function
_tcscpy(m_reportFileName, myIntValue);
Since you are using a C approach (I'm assuming that m_reportFileName is a raw C wchar_t array), you may want to consider just swprintf_s() directly:
#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);
}
In a more modern C++ approach, you may consider using std::wstring instead of the raw wchar_t array and std::to_wstring for the conversion.
In C++11:
wstring value = to_wstring(100);
Pre-C++11:
wostringstream wss;
wss << 100;
wstring value = wss.str();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With