char * to unsigned short *
I have to pass a string to a function, which takes input in "unsigned short *" format? How can I do this conversion?
Thanks in advance,
Prashant
Thanks in advance,
Prashant
If you function actually requires a Unicode string defined as unsigned short * (instead of usual const wchar_t *), it seems you first should convert your char * string to wchar_t * one (i.e. to Unicode), and then cast the pointer to unsigned short *.
One of solutions (for Visual Studio 2005), based on CA2W macro, is:
#include <atlbase.h>
#include <atlconv.h>
. . .
char s[] = "My string";
CA2W w = s;
unsigned short * p = (unsigned short *)(LPWSTR)w;
myFunction(p);
I hope this helps.