convert a STRING from LPCWSTR and vice versa c++

convert a STRING from LPCWSTR and vice versa c++

Enable MFC/ATL and use the CString object:

if (CString(request->id) != str)

Although its not clear to me what type STRING is either. I would just use CString for both:

STRING str = value // String value I want to compare
if (CString(request->id) != str)

Or just use the literal directly:

if (CString(request->id) != value)

Use the std::wstring type instead of a std::string in which case you have the .c_str() member function to work with or copy the string to a buffer using the MultiByteToWideChar() WinAPI function.

convert a STRING from LPCWSTR and vice versa c++

I ended up getting it to work using this process.

LPCWSTR lpc = LSTRING;
wcscmp(LPCWSTR, LPCWSTR)

Leave a Reply

Your email address will not be published. Required fields are marked *