C++ concat const char with char

Anw*_*med 1 c c++

我已经定义了一个值

extern char WEBSRV_ADMIN_ID[31];    char WEBSRV_ADMIN_ID[31]=   "admin";
Run Code Online (Sandbox Code Playgroud)

然后我想在char语句中使用用户名进入sql as

const char *pSQL[1];
pSQL[1] = "update websrv_config set admin_id='" + WEBSRV_ADMIN_ID + "'";
Run Code Online (Sandbox Code Playgroud)

但似乎有一个错误

error: invalid operands of types ‘const char [36]’ and ‘char [31]’ to binary ‘operator+’
Run Code Online (Sandbox Code Playgroud)

我怎么能克服它?

Kos*_*Kos 7

在C++中,使用std::string.它处理+将按你的意愿工作.

在C中,分配一个足够大的缓冲区来包含整个查询,并使用它逐个填充strncat.