how can I convert long to LPCWSTR in C++? I need function similar to this one:
LPCWSTR ToString(long num) {
wchar_t snum;
swprintf_s( &snum, 8, L"%l", num);
std::wstring wnum = snum;
return wnum.c_str();
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Your function is named “to string”, and it’s indeed easier (and more universal) to convert to a string than to convert “to LPCWSTR”:
If you have an API that needs a
LPCWSTR, you can usestd::wstring::c_str():