【发布时间】:2018-07-11 23:32:13
【问题描述】:
据我所知,在 C++ 中,您可以更改 (char *) 变量的值,但出现错误。
错误是:
error C2440: '=': cannot convert from 'const char [71]' to 'char *'
在我声明char* 变量之前:
char *sql;
然后我想用它,但是:
sql = "INSERT INTO person (id,name,last,age) " \
"VALUES (1, 'Paul', 'Yezh', 14); ";
在等号上我有这个错误。
【问题讨论】:
-
大部分重复:How to get rid of
deprecated conversion from string constant to ‘char*’warnings in GCC? 警告已被提升为错误,因为面对现实,将任何条带的const数据分配给非 const` 指针是一个坏主意。顺便说一句,忽略接受的答案。它不再有效。 -
Please don't post images of code。相反,将您的代码添加并 format 到帖子本身作为 text。
标签: c++