【发布时间】:2011-04-15 00:13:28
【问题描述】:
几天以来我一直在为代码苦苦挣扎,谁能帮忙
std::string str=uri_req1.substr(found+1);
char query[2000];
sprintf(query,"Insert into publish VALUES('%s','NO')",str);
我收到以下警告,但表中未插入值
warning: cannot pass objects of non-POD type ‘struct std::string’
through ‘...’; call will abort at runtime
warning: format ‘%s’ expects type ‘char*’, but
argument 3 has type ‘int’
我尝试过的另一件事是
string query;
query="Insert into publish values('";
query+=str;
query+="','NO')";
mysql_query(&mysql,query);
但这也从未奏效 请帮忙
【问题讨论】:
-
它告诉你它不喜欢
string,但喜欢char*。为什么不直接打电话给query.c_str()?