本程序由main.c和ops.h构成:
sq;ite3.h、sqlite3.c是官方提供的源代码文件和库文件。
less.bat是个文本查看器
main.c代码:
#include <stdio.h>
#include <stdlib.h>
#include "ops.h"
/* run this program using the console pauser or add your own getch,system("pause") or input loop */
void isInit() {
int init_rc = -1;
int initResultInput = 0;
printf("Whether to initialize the yoghurt system[0/1] :");
scanf("%d",&initResultInput);
printf("%d \n",initResultInput);
showDataMessage();
showMessageBar();
//判断是否要初始化数据
if(initResultInput == 1) {
printf("Signal[init_rc = -1]Failed! \n");
init_rc = initFunc();
if(init_rc != 0) {
printf("Initialization Failed,please clean up the initialization garbage manually,Signal[init_rc != 0]... \n");
} else {
printf("Signal[init_rc = %d]Success! \n",init_rc);
}
} else if(initResultInput == 1) {
printf("Stating... \n");
printf("Error :( \n");
}
int main() {
wel();
isInit();
writeLogTime("正在初始化系统...");
/*Some Values*/
int selectRoleValue;
//显示欢迎信息
welcome();
writeLogTime("进入FirstUI界面...");
firstUI:
while(1) {
//选择需要的操作
selectRole();
printf("请输入操作代码:");
getchar();
Sleep(200);
printf("\n");
if(selectRoleValue == 0) {
break;
if(selectRoleValue == 1) {
if(selectRoleValue == 2) {
inputError();
int userLoginFuncMsgRecv = 0;
//登录
userLogin();
//userLoginFuncMsgRecv = userLoginFunc();
if(userLoginFuncMsgRecv == 1 || userLoginFuncMsgRecv == 2) {
//注册
userReg();
userRegFunc();
//回到第一个界面
goto firstUI;
//退出
printf("Shutdown the System... \n");
showMessageBar_warning();
writeLogTime("系统退出...");
exit(0);
int subUser = 0;
if(userLoginFuncMsgRecv == 1) {
functionSelect();
if(userLoginFuncMsgRecv == 2) {
adminDialog();
systemFunc();
printf("请输入代码:");
int userSelectValue;
printf("您选择的是[%d] \n",userSelectValue);
showDataMessage();
switch(userSelectValue) {
case 0:
userKaiHu();
userKaiHuFunc();
writeLogTime("用户开户...");
case 1:
userXiaoHu();
userXiaoHuFunc();
writeLogTime("用户销户...");
case 2:
raiseMoney();
raiseMoneyFunc();
writeLogTime("用户存款...");
case 3:
reduiceMoney();
reduiceMoneyFunc();
writeLogTime("用户提款...");
case 4:
showTable();
writeLogTime("用户报表...");
showTime();
printf("请输入您的用户名:");
char un[20];
scanf("%s",&un);
char pw[20];
printf("请输入您的密码:");
long mm;
Sleep(100);
mm = getUserMoney(un,pw);
showUserMoney(mm);
case 5:
subUser = 1;
case 6:
systemStop();
adminDeleteLog();
removeLogFile();
case 7:
adminShowLog();
writeLogTime("查看日志文件...");
system("less ba.log");
case 8:
adminResetSystem();
writeLogTime("删除数据...");
removeDataFile();
writeLogTime("");
case 9:
writeLogTime("重新启动...");
case 10:
writeLogTime("密码更改...");
printf("暂不支持管理员密码更改和用户权限更改,请联系柜台,操作后台数据库!\n");
break;
default:
printf("操作失败! \n");
writeLogTime("SecondUI操作失败...");
if(subUser == 1) {
writeLogTime("返回FirstUI...");
return 0;
}
ops.h全部代码:
#include <windows.h>
#include <string.h>
#include <time.h>
//#include <sqlite3.h>
#include "sqlite3.h"
/*需求分析:
定义用户元数据,用户注册系统账号,注册元数据信息,保存在数据库中,但是银行卡处于冻结状态。
用户注册系统账号以后需要开户,读取银行卡ID信息和解冻银行卡状态。
用户注销银行卡的时候冻结银行卡ID信息。
*/
void wel(){
printf("yyy yyy ggggggggggg hhh tttt \n");
printf(" yyy yyy ggg ggg hhh ttt \n");
printf(" yyy yyy gggg gg hhh ttt \n");
printf(" yyy yyy ggggg gg hhh rrrr ttt \n");
printf(" yyy yyy oooooo gg gg hhh uuuu uuuuu rrr ttt \n");
printf(" yyyyyyy oo oo gg gggg hhh uuuu uuuu rrr tttttttttttttttttttttt \n");
printf(" yyy oo oo gg ggg hhh uuuu uuuu rrrr rrrr ttttttttttttttttttttttt \n");
printf(" yyy oo oo ggggg gggg hhhhhhhhhhhhhhhh uuu uuu rrrr rrrrrr ttt \n");
printf(" yyy oo oo gggg hhhhhhhhhhhhhhhhhh uuuu uuuu rrrrrr ttt \n");
printf(" yyy oo oo ggg hhh hhh uuu uuuu rrrr ttt \n");
printf(" yyy oo oo gggg hhh hhh uuu uuu rrr ttt \n");
printf(" yyy oo oo ggg ggg hhh hhh uuuu uuuuu rrr ttt \n");
printf(" yyy oo oo ggg ggg hhh hhh uuuuu uuuuu rrr ttt \n");
printf(" yyy oo oo ggg ggg hhh hhh uuuuuuuuuuuuuuuuuuuuuuu rrr ttt \n");
printf(" yyy oo oo ggg ggg hhh hhh uuuu rrr ttt ttttt \n");
printf(" yyy oooooo gggg hhh hhhhhhhhh uuuuu rrr ttttttt \n");
Sleep(100);
//启动系统显示的界面
void welcome() {
printf("+--------------------------------------------------------------+ \n");
printf("| 欢迎使用Yoghourt银行管理程序! | \n");
printf("|--------------------------------------------------------------| \n");
printf("|开发者信息: | \n");
printf("| 组名=2,Name=许俊杰,Class=[数据库核心开发] \n");
writeLogTime("正在启动...");
void selectRole() {
printf("| 登录=[0] | \n");
printf("| 注册=[1] | \n");
printf("| 退出=[2] | \n");
writeLogTime("FirstUI...");
//登录后可以进行的操作
void functionSelect() {
printf("| 开户=[0] | \n");
printf("| 销户=[1] | \n");
printf("| 存款=[2] | \n");
printf("| 取款=[3] | \n");
printf("| 报表=[4] | \n");
printf("| 返回=[5] | \n");
writeLogTime("UserInterface...");
//系统管理员额外的权限
void systemFunc() {
printf("| 删除日志=[6] | \n");
printf("| 查看日志=[7] | \n");
printf("| 删除数据=[8] | \n");
printf("| 重新启动=[9] | \n");
printf("| 密码更改=[10] | \n");
writeLogTime("AdminInterface...");
//显示普通的进度条,耗时操作
void showMessageBar() {
writeLogTime("发送消息...");
int i=0;
printf("0%%");
printf("=");
i++;
if(i > 55) {
printf("100%%");
printf("\n");
//显示警告进度条
void showMessageBar_warning() {
writeLogTime("显示警告操作");
printf("#");
//提交数据的时候显示
void showDataMessage() {
printf("|正在提交数据... | \n");
printf("+--------------------------------------------------------------+ \n");
/*显示系统警告简略信息*/
void systemStop() {
printf("**************************************************************** \n");
printf("***************************系统告警***************************** \n");
printf("**************************************************************** \n");
void userReg() {
void userLogin() {
void inputError() {
printf("*****************************:(********************************* \n");
void userKaiHu() {
printf("| 建行开户 | \n");
void userXiaoHu() {
printf("| 建行销户 | \n");
void raiseMoney() {
printf("| 便捷储蓄 | \n");
void reduiceMoney() {
printf("| 便捷取款 | \n");
void showTable() {
printf("| 存取明细 | \n");
//查看系统的日志记录的时候显示
void adminShowLog() {
printf("| 日志查看 | \n");
//重新初始化系统的时候显示
void adminResetSystem() {
printf("| 重置系统 | \n");
void adminDeleteLog() {
printf("| 删除日志 | \n");
void adminDialog() {
printf("| 管理员操作 | \n");
void showUserMoney(long moneyNumber) {
printf("| 您的余额: %d | \n",moneyNumber);
}
struct userInfo {
//int userID;数据库主键
char username[20];
char password[20];
char cardID[40];
int userAge;
char userBirthday[10];
int isUse;
char userSex[10];
int money;
char lastDate[20];
char userRegDate[40];
int priValue;
} userInput;
/*END*/
//显示时间
void showTime() {
struct timeData {
int td_year;
int td_mouth;
int td_day;
int td_hour;
int td_min;
int td_sec;
} xtimeData;
time_t now;
time(&now);
struct tm *tm_now;
tm_now = localtime(&now);
xtimeData.td_year = tm_now->tm_year + 1900;
xtimeData.td_mouth = tm_now->tm_mon + 1;
xtimeData.td_day = tm_now->tm_mday;
xtimeData.td_hour = tm_now->tm_hour;
xtimeData.td_min = tm_now->tm_min;
xtimeData.td_sec = tm_now->tm_sec;
printf("%d",xtimeData.td_year);
printf("年");
printf("月");
printf("日");
printf(" ");
printf(":");
printf(" ");
//创建日志文件
void touchLogFile() {
FILE *fp = fopen("ba.log","w+");
fclose(fp);
void removeLogFile() {
system("rease ba.log");
void removeDataFile(){
system("rease data.db");
//写入文件日志时间
void writeLogTime(char wmsg[1024]) {
FILE *logF = fopen("ba.log","a");
fprintf(logF,"%d年","%d月","%d日","%d:","%d "," ");
fclose(logF);
/*
int userLoginFunc() {
int userLoginFuncMsg = 0;
//select
sqlite3 *db3 = NULL;
int rc3 = sqlite3_open("data.db",&db3);
if( rc3 != 0) {
printf("Open database error! \n");
writeLogTime("数据库打开失败[DB3]");
return -1;
printf("Open database is OK!\n");
writeLogTime("数据库打开成功[DB3]");
sqlite3_stmt* stmt3 = NULL;
char sql_3[1024];
printf("请输入您的用户名:");
printf("请输入您的密码:");
printf("\n");
printf("making select sql... \n");
sprintf(sql_3,"select password from userinfo where username='%s'",userInput.username);
rc3 = sqlite3_prepare_v2(db3,sql_3,-1,&stmt3,NULL);
if(rc3 != sqlITE_OK) {
printf("Failed to prepare: %s \n",sqlite3_errmsg(db3));
writeLogTime("sql指令准备失败[DB3]");
writeLogTime("sql指令准备成功[DB3]");
rc3 = sqlite3_step(stmt3);
if(rc3 == sqlITE_ROW) {
const char* resPassword = (const char*) sqlite3_column_text(stmt3,0);
//printf("%s",resPassword);
int cmpRes = strcmp(resPassword,userInput.password);
if(cmpRes == 0) {
printf("您已经通过登录安全检查... \n");
printf("正在登录... \n");
writeLogTime("sql指令执行成功[DB3]");
userLoginFuncMsg = 1;
int getpriValues = getpriValue(userInput.username,80); white-space: pre;">userLoginFuncMsg = getpriValues +1;//1 2
} else if(cmpRes > 0 || cmpRes < 0) {
printf("登录失败,您输入的用户名或密码错误或包含空格... \n");
printf("请您注册,谢谢合作... \n");
} else if(rc3 == sqlITE_DONE) {
printf("Finish. \n");
writeLogTime("sql指令执行完毕[DB3]");
printf("Error: %s \n",80); white-space: pre;">writeLogTime("sql指令执行失败[DB3]");
}
sqlite3_finalize(stmt3);
printf("SELECT : success!\n");
sqlite3_close(db3);
printf("Closing database... \n");
printf("SELECT data is successfully !\n");
return userLoginFuncMsg;
用户注册函数,用户输入元数据,向表中插入一条数据,银行卡处于不可用状态,用户权限是普通用户
void userRegFunc() {
//MysqL : SELECT * FROM 表名 ORDER BY 表_ID DESC LIMIT 1
//sqlServer/Oracle : SELECT TOP 1 * FROM 表名 ORDER BY 表_ID DESC
printf("您的用户ID为:\n");
//int id = getId();
sqlite3 *db9 = NULL;
int rc9 = sqlite3_open("data.db",&db9);
if( rc9 != 0) {
writeLogTime("数据库打开失败[DB9]");
return;
writeLogTime("数据库打开成功[DB9]");
sqlite3_stmt* stmt9 = NULL;
int resId = 0;
char sql_9[1024] = "select id from userinfo order by id desc limit 1";
rc9 = sqlite3_prepare_v2(db9,sql_9,&stmt9,80); white-space: pre;">if(rc9 != sqlITE_OK)
{
sqlite3_errmsg(db9));
writeLogTime("sql指令准备失败[DB9]");
writeLogTime("sql指令准备成功[DB9]");
while(1)
rc9 = sqlite3_step(stmt9);
if(rc9 == sqlITE_ROW)
resId = sqlite3_column_int(stmt9,80); white-space: pre;">writeLogTime("sql指令执行成功[DB9]");
else if(rc9 == sqlITE_DONE)
writeLogTime("sql指令执行完毕[DB9]");
else
writeLogTime("sql指令执行失败[DB9]");
sqlite3_finalize(stmt9);
sqlite3_close(db9);
int ids = resId + 1;
printf("请输入您的用户名[不超过15字符]:");
printf("您输入的用户名是==%s==\n",userInput.username);
printf("请输入您的密码[不超过8个字符]:");
printf("您输入的密码是==%s==\n",userInput.password);
printf("请输入您的卡号[默认0000000000000000]:");
printf("您输入的卡号是==%s==\n",userInput.cardID);
printf("请输入您的年龄:");
printf("您输入的年龄是==%d==\n",userInput.userAge);
printf("请输入您的您的出生日期[YYYYMMDD]:");
printf("您输入的出生日期是==%s==\n",userInput.userBirthday);
printf("您的账户不可用,请开户激活!\n");
writeLogTime("取消激活账户");
userInput.isUse = 0;
printf("请输入您的性别[man/woman]:");
printf("您输入的性别是==%s==\n",80); white-space: pre;">Sleep(200);
printf("你的存款为0,请激活后存款!\n");
userInput.money = 0;
writeLogTime("删除存款数据");
printf("您最后一次登录的时间是:");//显示最后一次登录的时间
xtimeData.td_sec = tm_now->tm_sec;
sprintf(userInput.lastDate,"%dY%dM%dD %d:%d:%d",xtimeData.td_year,xtimeData.td_mouth,xtimeData.td_day,xtimeData.td_hour,xtimeData.td_min,80); white-space: pre;">printf("%s \n",userInput.lastDate);
printf("您的注册日期是:");
sprintf(userInput.userRegDate,userInput.userRegDate);
printf("您的权限是[priValue = 0]\n");
writeLogTime("更改用户权限...");
userInput.priValue = 0;
fflush(stdin);
//insertsql
sqlite3 *db2 = NULL;
int rc2 = sqlite3_open("data.db",&db2);
if( rc2 != 0) {
writeLogTime("数据库打开失败[DB2]");
writeLogTime("数据库打开成功[DB2]");
sqlite3_stmt* stmt2 = NULL;
printf("making insert sql... \n");
char sql_2[1024];
sprintf(sql_2,"INSERT INTO userinfo(id,username,password,card_id,age,birthday,is_use,user_sex,money,last_date,reg_date,pri_value) VALUES (%d,'%s',%d,%d)",ids,userInput.username,userInput.password,userInput.cardID,userInput.userAge,userInput.userBirthday,userInput.isUse,userInput.userSex,userInput.money,userInput.lastDate,userInput.userRegDate,userInput.priValue);
printf("==%s==",sql_2);
/*
char sql_2[1024] ="INSERT INTO userinfo(id,pri_value) VALUES (:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11,:12)";
"create table IF NOT EXISTS userinfo ("
"id integer primary key,"
"username text,80); white-space: pre;"> "password text,80); white-space: pre;"> "card_id text,80); white-space: pre;"> "age integer,80); white-space: pre;"> "birthday text,80); white-space: pre;"> "is_use integer,80); white-space: pre;"> "user_sex text,80); white-space: pre;"> "money integer,80); white-space: pre;"> "last_date text,80); white-space: pre;"> "reg_date text,80); white-space: pre;"> "pri_value integer"
")";
*/
// 绑定参数
sqlite3_bind_int(stmt2,1,id); //确定用户数据表ID,主键
sqlite3_bind_text(stmt2,2,NULL); //绑定用户名
登录时间
注册日期
//sqlite3_bind_int(stmt2,12,userInput.priValue); //绑定权限位
// 初始化sql Statement对象
rc2 = sqlite3_prepare_v2(db2,sql_2,&stmt2,80); white-space: pre;">if(rc2 != sqlITE_OK) {
sqlite3_errmsg(db2));
writeLogTime("sql指令准备失败[DB2]");
writeLogTime("sql指令准备成功[DB2]");
// 执行sql
rc2 = sqlite3_step(stmt2);
if(rc2 != sqlITE_DONE) {
printf("error: %s \n",80); white-space: pre;">writeLogTime("sql指令执行失败[DB2]");
sqlite3_finalize(stmt2);
writeLogTime("sql指令执行成功[DB2]");
printf("INSERT : success!\n");
sqlite3_close(db2);
printf("Insert data is successfully !\n");
用户开户函数:通过筛选银行卡ID信息,更新用户的银行卡信息冻结状态
void userKaiHuFunc() {
printf("请输入您的银行卡ID:");
//update
sqlite3 *db4 = NULL;
int rc4 = sqlite3_open("data.db",&db4);
printf("Open database is successfully... \n");
if( rc4 != 0) {
printf("Error!\n");
writeLogTime("数据库打开失败[DB4]");
writeLogTime("数据库打开成功[DB4]");
printf("making update sql... \n");
char sql_4[1024];
sqlite3_stmt* stmt4 = NULL;
sprintf(sql_4,"update userinfo set is_use = 1 where username = '%s' and password = '%s'",userInput.password);
rc4 = sqlite3_prepare_v2(db4,sql_4,&stmt4,NULL);
if(rc4 != sqlITE_OK) {
printf("Failed to prepare: %s \n",sqlite3_errmsg(db4));
writeLogTime("sql指令准备失败[DB4]");
return ;
writeLogTime("sql指令准备成功[DB4]");
char *errmsg;
rc4 = sqlite3_exec(db4,NULL,&errmsg);
if(errmsg == NULL) {
printf("UPDATE database is OK... \n");
writeLogTime("sql指令执行成功[DB4]");
printf("Error,%s \n",errmsg);
sqlite3_close(db4);
int sqlite3_exec(
sqlite3*,
const char *sql,80); white-space: pre;"> int (*callback)(void*,int,char**,char**),80); white-space: pre;"> void *,80); white-space: pre;"> char **errmsg
);
各个参数的意义为:
callback回调函数
void *回调函数的第一个参数
int callback(void *params,int column_size,char **column_value,char **column_name){
每一个参数意义如下:
params是sqlite3_exec传入的第四个参数
column_size是结果字段的个数
column_value是返回记录的一位字符数组指针
column_name是结果字段的名称
通常情况下callback在select操作中会使用到,尤其是处理每一行记录数。返回的结果每一行记录都会调用下“回调函数”。 如果回调函数返回了非0,那么sqlite3_exec将返回sqlITE_ABORT,并且之后的回调函数也不会执行,同时未执行的子查询也不会继续执行。
对于更新、删除、插入等不需要回调函数的操作,sqlite3_exec的第三、第四个参数可以传入0或者NULL。
用户销户函数:通过筛选银行卡ID信息,更新用户的银行卡信息冻结状态
void userXiaoHuFunc() {
//update
sqlite3 *db5 = NULL;
int rc5 = sqlite3_open("data.db",&db5);
Sleep(200);
if( rc5 != 0) {
writeLogTime("数据库打开失败[DB5]");
printf("Open database is successfully... \n");
writeLogTime("数据库打开成功[DB5]");
char sql_5[1024];
sqlite3_stmt* stmt5 = NULL;
sprintf(sql_5,"update userinfo set is_use = 0 where username = '%s' and password = '%s'",80); white-space: pre;">rc5 = sqlite3_prepare_v2(db5,sql_5,&stmt5,80); white-space: pre;">if(rc5 != sqlITE_OK) {
sqlite3_errmsg(db5));
writeLogTime("sql指令准备失败[DB5]");
writeLogTime("sql指令准备成功[DB5]");
rc5 = sqlite3_exec(db5,80); white-space: pre;">writeLogTime("sql指令执行成功[DB5]");
sqlite3_close(db5);
long getUserMoney(char userName[20],char passWord[20]) {
printf("Get data as message for sql userName==%s== && passWord==%s== \n",userName,passWord);
sqlite3 *db8 = NULL;
int rc8 = sqlite3_open("data.db",&db8);
if( rc8 != 0) {
writeLogTime("数据库打开失败[DB8]");
writeLogTime("数据库打开成功[DB8]");
char sql_8[1024];
long resMoney = 0;
sqlite3_stmt* stmt8 = NULL;
sprintf(sql_8,"select money from userinfo where username='%s' and password='%s'",80); white-space: pre;">rc8 = sqlite3_prepare_v2(db8,sql_8,&stmt8,80); white-space: pre;">if(rc8 != sqlITE_OK) {
sqlite3_errmsg(db8));
writeLogTime("sql指令准备失败[DB8]");
writeLogTime("sql指令准备成功[DB8]");
rc8 = sqlite3_step(stmt8);
if(rc8 == sqlITE_ROW) {
resMoney = sqlite3_column_int(stmt8,80); white-space: pre;">} else if(rc8 == sqlITE_DONE) {
writeLogTime("sql指令执行完毕[DB8]");
writeLogTime("sql指令执行失败[DB8]");
sqlite3_finalize(stmt8);
sqlite3_close(db8);
printf("SELECT data is successfully !\n");
return resMoney;
int getpriValue(char userName[20],80); white-space: pre;">int resPri = 0;
resPri = sqlite3_column_int(stmt8,80); white-space: pre;">writeLogTime("sql语句执行失败[DB8]");
return resPri;
void raiseMoneyFunc() {
printf("请输入您的存款金额数量[每次只允许储蓄¥100以内]:");
sqlite3 *db6 = NULL;
int rc6 = sqlite3_open("data.db",&db6);
if( rc6 != 0) {
writeLogTime("数据库打开失败[DB6]");
writeLogTime("数据库打开成功[DB6]");
long quonMoney = getUserMoney(userInput.username,80); white-space: pre;">long modifyMoney = userInput.money + quonMoney;
char sql_6[1024];
sqlite3_stmt* stmt6 = NULL;
sprintf(sql_6,"update userinfo set money = %d where username = '%s' and password = '%s'",modifyMoney,80); white-space: pre;">rc6 = sqlite3_prepare_v2(db6,sql_6,&stmt6,80); white-space: pre;">if(rc6 != sqlITE_OK) {
sqlite3_errmsg(db6));
writeLogTime("sql指令准备失败[DB6]");
writeLogTime("sql指令准备成功[DB6]");
rc6 = sqlite3_exec(db6,80); white-space: pre;">writeLogTime("sql指令执行成功[DB6]");
writeLogTime("sql指令执行失败[DB6]");
sqlite3_close(db6);
void reduiceMoneyFunc() {
printf("请输入取款金额数量[每次只允许取款¥1000以内]:");
sqlite3 *db7 = NULL;
int rc7 = sqlite3_open("data.db",&db7);
if( rc7 != 0) {
writeLogTime("数据库打开失败[DB7]");
writeLogTime("数据库打开成功[DB7]");
long modifyMoney = quonMoney - userInput.money;
if(modifyMoney < 0) {
printf("您还没有存款哦... \n");
printf("系统忠实记录了您已经贷款... \n");
printf("贷款信息写入... \n");
char sql_7[1024];
sqlite3_stmt* stmt7 = NULL;
sprintf(sql_7,80); white-space: pre;">rc7 = sqlite3_prepare_v2(db7,sql_7,&stmt7,80); white-space: pre;">if(rc7 != sqlITE_OK) {
sqlite3_errmsg(db7));
writeLogTime("sql指令准备失败[DB7]");
writeLogTime("sql指令准备成功[DB7]");
rc7 = sqlite3_exec(db7,80); white-space: pre;">sqlite3_close(db7);
/*程序的初始化函数*/
int initFunc() {
printf("Initializing... \n");
//创建日志文件
printf("Create log file...\n");
//touchLogFile();
printf("Create data file... \n");
sqlite3 *db = NULL;
//打开数据库
int rc = sqlite3_open("data.db",&db);
//判断数据库是否打开
if( rc != 0) {
sqlite3_stmt* stmt = NULL;
printf("making create table sql... \n");
//创建sql语句
char sql[1024] =
"create table IF NOT EXISTS userinfo ("
"id integer primary key AUTOINCREMENT,80); white-space: pre;">//准备sql语句
rc = sqlite3_prepare_v2(db,sql,&stmt,80); white-space: pre;">if(rc != sqlITE_OK) {
sqlite3_errmsg(db));
//执行sql语句
rc = sqlite3_step(stmt);
if(rc != sqlITE_DONE) {
sqlite3_finalize(stmt);
sqlite3_close(db);
printf("Create a datasheet successfully !\n");
printf("Wait for the system to start... \n");
system("cls");
int gangCount = 0;
for(gangCount;gangCount < 10;gangCount++){
printf("|");
printf("/");
printf("-");
printf("\\");
Sleep(100);
}
原文链接:https://www.f2er.com/sqlite/198092.html