convert wchar* to byte*
-
You can simply cast the pointer to PBYTE or BYTE*
wchar_t buf[] = L"Hello World"; PBYTE pBytes = (PBYTE)buf;
Best Wishes, -David Delaune -
hey, its not converting fully... if i have wchar* q = "AJC"; when i convert it using ur method, PBYTE pbytes = (PBYTE)q; its giving pbytes as C alone... can u shed some light on it? Thanks, Rakesh
Hi Rakesh,
wchar* q = "AJC";
This line of code is not correct. You cannot assign a pointer to an array of character value. It appears to me that you need some basic C/C++ tutorials. I found these on the net: http://www.cplusplus.com/doc/tutorial/ntcs/[^] http://www.cplusplus.com/forum/beginner/21/[^] http://www.cplusplus.com/doc/tutorial/pointers/[^] I think if you read these tutorials you may understand why your code does not work. Best Wishes, -David Delaune
-
hey, its not converting fully... if i have wchar* q = "AJC"; when i convert it using ur method, PBYTE pbytes = (PBYTE)q; its giving pbytes as C alone... can u shed some light on it? Thanks, Rakesh
wchar_t* q = L"AJC";
This creates a pointer to a wide character string. To convert this toBYTE*
which is a multi-byte character string you can use the WideCharToMultiByte[^] API. But then aBYTE
pointer will not suffice. You will need aBYTE
array declaration. Something like -BYTE bytes[255];
«_Superman_» I love work. It gives me something to do between weekends.