Proper way of converting int to LPCWSTR (Win32)
11,244
Solution 1
use wsprintf
It allows you to compose a string the same way printf allows you to print a line of text.
Solution 2
If you're looking for more than just INT to LPWSTR conversion (such as formatting), I'd suggest StringCchPrintfW.
![Daniel Goldberg](https://i.stack.imgur.com/Ek7wq.jpg?s=256&g=1)
Comments
-
Daniel Goldberg about 2 years
I'm attempting to learn basic Win32 programming and running into a frustrating problem. I wish to convert a variable (Call it NumClicks) and display it as the application name (as part of a string). From what I've seen, going from int + some block of text to a char* is problematic, because converting it to the requisite end data type(LPCWSTR) is more difficult than a straight casting.
Any ideas or links?
-
Matteo Italia about 14 yearsIn which way it doesn't fully solve your problem? By the way, you'd better use the more secure (and still standard) wsnprintf.