我正在尝试使 C 程序正常工作,但我很生气。这是我为查找错误而简化的代码:
#include <stdio.h>
#include <unistd.h>
#include <sqlite3.h>
int main(){
sqlite3 *conn;
sqlite3_stmt *res;
const char *tail, *sqlresult;
sqlite3_open("cubecat", &conn);
char buffer,query;
int id;
id= 1;
buffer = 'a';
if(buffer == 'a') snprintf(&query,100,"SELECT start FROM payloads WHERE id=%d", id);
printf("%s",&query);
int error = sqlite3_prepare_v2(conn, &query, 100, &res, &tail);
printf("%d",error);
}
错误正是在“sqlite_prepare_v2”函数上,因为如果我评论那行,就没有分段错误。
先感谢您!