作业 把dic.txt 导入数据库里

本文介绍了如何将dic.txt文本文件的内容导入到SQLite数据库中,包括步骤和可能遇到的问题解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

#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,\
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值