Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/63.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C、 如何传递sqlite3数据库句柄_C_Sqlite - Fatal编程技术网

C、 如何传递sqlite3数据库句柄

C、 如何传递sqlite3数据库句柄,c,sqlite,C,Sqlite,我正在尝试制作一些用于sqlite数据库的UTIL。 为此,我创建了sqlite3_ut.h和sqlite3_ut.c文件 sqlite_ut.h #ifndef sqlite3_ut_h #define sqlite3_ut_h #include <stdio.h> #include "sqlite3.h" int drop_table(sqlite3 handle); #endif sqlite_ut.h包含在主文件中 sqlite3 *db; int rc = sql

我正在尝试制作一些用于sqlite数据库的UTIL。 为此,我创建了sqlite3_ut.h和sqlite3_ut.c文件

sqlite_ut.h

#ifndef sqlite3_ut_h
#define sqlite3_ut_h

#include <stdio.h>
#include "sqlite3.h"

int drop_table(sqlite3 handle);

#endif
sqlite_ut.h包含在主文件中

sqlite3 *db;

int rc = sqlite3_open("m_test.db", &db);
if (rc)...

//error here
int dropped = drop_table(db);
显然,我不能正确地将打开的数据库的句柄转移到drop_table函数,该函数是sqlite3类型的


如何使用建议的程序配置来实现这一点?

SQLite3句柄的类型是
SQLite3*
,而不是
SQLite3
。重新定义
drop\u表
,如下所示:

int drop_table(sqlite3 *handle) { … }

为什么不呢,你试过了吗?你有错误吗?嘿,乔。我在这里遇到了麻烦。用C标题和C文件编译C++程序,现在显示“未定义的引用DROPH表”消息。怎么办?谢谢。我将尽快尝试此选项:)
int drop_table(sqlite3 *handle) { … }