c++wcharlpcwstr

'Cannot add two pointers' adding LPCWSTR with WCHAR


I declared two variable like:

WCHAR w_ErrorMessage[256];
LPCWSTR lp_ErrMsg;

The first variable is for returned SQLite error message, And the second variable is for MessageBox text. I tried and wrote this code:

lp_ErrMsg = L"Database sql error: " + WCHAR(w_ErrorMessage);
MessageBox(0, lp_ErrMsg, L"Error", MB_ICONERROR | MB_OK);

but something like this shows for message: ScreenShot

If I remove the WCHAR behind the w_ErrorMessage variable I get the "Error: Cannot add two pointers".

I want MessageBox show error: SQLite Error: %TheActualErrorMessage%. How can I do that?


Solution

  • The + operator is not used to concatenate strings in C/C++. Use wcscat function instead.