65,210
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
int main()
{
char sql[128] = {0};
string name;
cout<<"please enter the name."<<endl;
cin>>name;
sprintf(sql, "select * from user where loadName='%s'", name.c_str());
cout<<sql<<endl;
return 0;
}
please enter the name.
abc
select * from user where loadName='abc'
Press any key to continue
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
int main()
{
char sql[128] = {0};
string name;
cin>>name;
sprintf(sql, "select * from user %s", name.c_str());
cout<<sql<<endl;
return 0;
}
#include "iostream"
#include "string"
using namespace std;
int main()
{
string sql;
string name;
cin>>name;
sql = string("select * from user = \"") + name + string("\"");
cout<<sql<<endl;
return 0;
}