'无法添加两个指针'添加LPCWSTR和WCHAR

时间:2021-11-16 20:13:49

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:

第一个变量用于返回的SQLite错误消息,第二个变量用于MessageBox文本。我试过写了这段代码:

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

但这样的事情显示消息:ScreenShot

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

如果我删除w_ErrorMessage变量后面的WCHAR,我得到“错误:无法添加两个指针”。

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

我想要MessageBox显示错误:SQLite错误:%TheActualErrorMessage%。我怎样才能做到这一点?

1 个解决方案

#1


0  

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

+运算符不用于在C / C ++中连接字符串。请改用wcscat函数。

#1


0  

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

+运算符不用于在C / C ++中连接字符串。请改用wcscat函数。