std::string sql("INSERT INTO page(url, content) VALUES('" + url + "','" + content + "')");
int res = mysql_query(cnn, sql.c_str());
//注:url和content都是string类型,该程序编译通过
string::size_type pos;
while((pos = content.find("\'")) != string::npos)
{
content.replace(pos, 1, "&someflag"); //将单引号替换
}