0

I'm trying to convert LPWSTR to LPSTR withi this:

LPWSTR *argvw;
int argc;
argvw = CommandLineToArgvW(GetCommandLineW(), &argc);

LPSTR argv = new CHAR[argvw->size()+1];
WideCharToMultiByte(CP_ACP, 0, argvw->c_str(), -1, argv, (int)argvw->size()+1, 0, 0);

but I'm getting this:

main.cpp:14: error: request for member 'size' in '* argvw', which is of non-clas
s type 'WCHAR*'
main.cpp:15: error: request for member 'c_str' in '* argvw', which is of non-cla
ss type 'WCHAR*'
main.cpp:15: error: request for member 'size' in '* argvw', which is of non-clas
s type 'WCHAR*'

How should I convert this properly?

Regards

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Ancient Dragon
0

argvw is nothing more than a pointer and pointers don't have methods. If you want to find the length of the string then call wcslen(argvw), which is the UNICODE version of strlen()

>>argvw->c_str(),
Same problem as above -- you are attempting to treat a poointer as if it were std::string class. Doesn't work like that.

Edited by Ancient Dragon: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.