#include <stdio.h>
#include <sqlite3.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
int main(int argc, const char *argv[])
{
//创建并打开数据库
sqlite3 *db = NULL;
if(sqlite3_open("./my.db",&db)!=SQLITE_OK)
{
fprintf(stderr,"sqlite3_open:%s\n",sqlite3_errmsg(db));
fprintf(stderr,"sqlite3_open:%d\n",sqlite3_errcode(db));
return -1;
}
//创建一张表格
char* errmsg = NULL;
char sql[128] = "create table if not exists dict(word char, mean char);";
if(sqlite3_exec(db,sql,NULL,NULL,&errmsg)!=SQLITE_OK)
{
fprintf(stderr,"sqlite3_exec:%s\n",errmsg);
return -1;
}
//打开要导入的文件
FILE* fd = fopen("./dict.txt","r");
if(fd==NULL)
{
perror("fopen");
return -1;
}
char buf[64] = "";
char word[64] = "";
char mean[64] = "";
int i,j;
while(1)
{
bzero(buf,sizeof(buf));
英文字典导入数据库
最新推荐文章于 2023-09-04 19:44:26 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)