converting a char[] using MultibytetoWideChar() works, but when I try to use swprintf() I get the following error
error C2664: 'swprintf' : cannot convert parameter 2 from 'char [6]' to 'const unsigned short *'
(code) swprintf(errormsg,"%d,%d",
any ideas on how to fix this?
Main Topics
Browse All Topics





by: _nn_Posted on 2003-08-08 at 12:15:52ID: 9110507
TCHAR is a macro. Depending on whether you compile with _UNICODE or not, it will generate either "wchar_t" or "char"
library/de fault.asp? url=/libra ry/ en-us/w cesdkr/htm l/_wcesdk_ win32_mult ibytetowid echar.asp
g)
Normally, if you're using TCHAR, then you should use the _stprintf macro instead of the sprintf() function.
Now, since you're coding from WinCE, you most probably have _UNICODE defined, so use swprintf().
Finally, if you really need to convert a char[] or char* strings to unicode strings then have a look at the MultiByteToWideChar() API. See
http://msdn.microsoft.com/
or maybe more simply (untested) use a CString object to do the conversion :
(LPCWSTR)CString(szMyStrin