Hello i need some help
I want to convert a char* in an unsigned short* in order to use the GDI fonction DrawText.
In the same way I want to convert a float -> unsigned short*
Someone can help me please ?
Swann
Or, to do it without writing a function specifically for that, use mbstowcs() and wcstombs(). To convert the float to an unsigned short*, do you mean that you want it to be a string? If so, then you'll be wanting sprintf(). I can;t remeber all of the parameters and exactly how they work, but they are all in the MSDN help. HTH
Well, this doesn't really need to be a separate function either. The w[strlen(s)]=0; is not necessary:
cbMultiByte
If this parameter is -1, the function processes the entire input string including the null terminator. The resulting wide character string therefore has a null terminator, and the returned length includes the null terminator.
If you've got a static buffer you're translating the string into then you can just do a simple call:
TCHAR szOut[1024];
WideCharToMultiByte(CP_ACP, 0, s, -1, szOut, sizeof(szOut)/sizeof(TCHAR));
_stprintf is the TCHAR version of sprintf.
Dan East