#include <stdio.h> #include <sqlite3.h> #include <stdlib.h> #include <string.h> sqlite3* db = NULL; void do_insert(void) { int id =0; int i; char word[20]=""; char sq[70]=""; char fy[50]=""; FILE * fd = fopen("./dict.txt","r"); int index = 0; char * res= NULL; char sql[100]=""; char * errmsg = NULL; while(1) { id++; index =0; bzero(word,sizeof(word)); bzero(fy,sizeof(fy)); bzero(sql,sizeof(sql)); res = fgets(sq,sizeof(sql),fd); // 一行行读取数据 if (NULL == res) { break; } while(1) { printf("%d\n",index); if (sq[index]==' '&&sq[index+1]==' ') { for (i=0;i<index;i++) { word[i]=sq[i]; } strcpy(fy,sq+2+index); sprintf(sql,"insert into stu values (%d,\
作业 把dic.txt 导入数据库里
于 2022-11-29 22:01:45 首次发布