代码有效,但是我正在寻找一种方法来将打印到屏幕上的数据存储在变量中
static int callback(void *data, int argc, char **argv, char **azColName) {
int i;
fprintf(stderr, "%s: ", (const char*)data);
for (i = 0; i<argc; i++) {
printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
}
printf("\n");
return 0;
}
int rc;
std::string sql;
char *zErrMsg = 0;
const char* data = "Callback function called";
rc = sqlite3_open("data.db", &db);
sql = "SELECT ID FROM USER WHERE ID='e'";
rc = sqlite3_exec(db, sql.c_str(), callback, NULL, &zErrMsg);
这正在打印所需的结果,但是如何将其保存为字符串