01.思维导图
02
使用 sqlite3_exec 函数,执行如下几个语句
create table if no exists tb(
name text primary key,
pswd text not null
);
insert into tb(name,pswd) values("123","abcdefg")
char code_pswd[20] = ""
printf("请输入新的密码:");
scanf("%s",code_pswd)
执行语句 :update tb set pswd = code_pswd where name = "123";
#include <25051head.h>
int main(int argc, const char *argv[])
{
sqlite3* db=NULL;
char* err_msg=NULL;
int rc=sqlite3_open("./students.db",&db);
if(rc!=SQLITE_OK){
fprintf(stderr,"sqlite3_open_error:%s\n",sqlite3_errmsg(db));
sqlite3_close(db);
return 1;
}
char* create_table_sql="create table if not exists tb(name text primary key,pswd text not null);";
sqlite3_exec(db,create_table_sql,0,0,&err_msg);
char* insert_sql="insert into tb(name,pswd) values('123','abcdefg');";
sqlite3_exec(db,insert_sql,0,0,&err_msg);
char code_pswd[20]="";
printf("请输入新的密码:");
scanf("%s",code_pswd);
char update_sql[100]="";
snprintf(update_sql,sizeof(update_sql),"update tb set pswd='%s' where name='123';",code_pswd);
sqlite3_exec(db,update_sql,0,0,&err_msg);
sqlite3_close(db);
return 0;
}
#ifndef __25051HED_H__
#define __25051HED_H__
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <ctype.h>
#include <sys/types.h>//引入open函数
#include <sys/stat.h>//stat lstat:
#define _GNU_SOURCE
#include <fcntl.h> //dup3
#include <unistd.h>//引入 getdtablesize函数,获取文件描述符个数,包含close函数 dup,dup2
#include <time.h>
#include <sys/wait.h>
#include <pthread.h>//引入线程
#include <semaphore.h>//引入信号量
#include <signal.h>//引入管道通信信号
#include <sys/ipc.h>//ftok shmget
#include <sys/msg.h>//msgget
#include <sys/shm.h>//引入共享内存的
#include <sys/sem.h>//semget引入信号灯集
#include <arpa/inet.h>//大端转换函数--->网络编程
#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/socket.h>//引入套接字
#include <sys/select.h>
#include <poll.h>
#include <sys/epoll.h>
#include <sqlite3.h>//引入sqlite3数据库
int P(int sem_num,int sem_op,int semid);
int V(int sem_num,int sem_op,int semid);
#if 0
typedef struct sockaddr_in addr_in_t;
typedef struct sockaddr addr_t;
typedef struct sockaddr_un addr_un_t;
#endif
#define ERRLOG(msg) do{printf("__%d__",__LINE__);fflush(stdout);perror(msg);return -1;}while(0)
#endif