1、SQLite嵌入式数据库的配置、编译与安装;
2、设计两个数据表,一个为 students表,包含学号、姓名、班级共3个字段;一个表为score表,包含学号、实验1、实验2、实验3、平时成绩和测试成绩共6个字段。
3、设计一个学生管理系统,编写一个 SQLite应用程序stu_man.c,启动并打开 test. db程序后,显示功能菜单提示用户操作:①输入学生信息;②输入学生成绩;③打印学生成绩;④退出程序。
Score.c代码:
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <sqlite3.h>
sqlite3 *db = NULL; // 一个打开的数据库实例
//获取进程自身路径
size_t get_executable_path(char* processdir, char* processname, size_t len)
{
char* path_end;
if (readlink("/proc/self/exe", processdir, len) <= 0)
{
return -1;
}
path_end = strrchr(processdir, '/');
if (path_end == NULL)
{
return -1;
}
++path_end;
strcpy(processname, path_end);
*path_end = '\0';
return (size_t)(path_end - processdir);
}
void newStudent()
{
char name[1024] = { 0 };
char studentId[1024] = { 0 };
int classId = 0;
sqlite3_stmt *stmt;
const char* sql;
printf("请输入名字:");
scanf("%s", &name);
printf("请输入学号:");
scanf("%s&#