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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.