pampa34
asked on
Convert from LPSTR to LPCWSTR and LPSTR to char*
Hi,
Could somebody provide me an URL or a sample code to convert a LPSTR string to LPCWSTR and from LPSTR string to char*.
Thanks in advance,
Pampa
Could somebody provide me an URL or a sample code to convert a LPSTR string to LPCWSTR and from LPSTR string to char*.
Thanks in advance,
Pampa
windows project can use the MultiByteToWideChar API function to convert an ANSI string to a UNICODE string.
No conversion is required for converting a LPSTR to char*.
Example:
LPSTR str1 = "Hello World";
char* str2 = str1;
char str3[33];
strcpy(str3, str1);
Example:
LPSTR str1 = "Hello World";
char* str2 = str1;
char str3[33];
strcpy(str3, str1);
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
you should be able to simply typecast them eg.
LPCWSTR mylpcwstr = (LPCWSTR) mylpstr;
char *mypchar = (char *) mylpstr;
this has always worked for me :)
LPCWSTR mylpcwstr = (LPCWSTR) mylpstr;
char *mypchar = (char *) mylpstr;
this has always worked for me :)