math/main.c

76 lines
2.4 KiB
C

//
// Created by zhang on 2024/12/8.
//
#include <stdio.h>
#include <stdbool.h>
#include <windows.h>
#include "./include/function.h"
#include "./include/ui.h"
#include "./include/extern.h"
#include "./include/curses.h"
char Username[15];
char class[15];
void mytest();
int main() {
initscr(); // 初始化curses
cbreak(); // 禁用行缓冲
noecho(); // 不显示输入字符
curs_set(0); // 隐藏光标
keypad(stdscr, TRUE); // 启用键盘按键的特殊处理
mousemask(ALL_MOUSE_EVENTS, NULL); // 启用鼠标事件
timeout(100); // 设置输入超时,防止程序卡死
int recall;
char *errmsg[100];
db_create(&recall,errmsg);
if(recall!=0){
fprintf(stderr,"%s\ninput any key to exit.",errmsg);
getchar();
exit(0);
}
//int code=TEACHER_UI;
int code=Welcome_ui();
while(1){
switch(code){
case WELCOME_UI:code=Welcome_ui();break;
case LOGIN_UI:code=Login_ui();break;
case SIGNIN_UI:code=Signin_ui();break;
case STUDENT_UI:code=StudentsDesktop_ui();break;
case TEACHER_UI:code=TeachersDesktop_ui();break;
case T_PROBLEM_UI:code=t_problem_ui();break;
case ADD_UI:code=add_ui();break;
case 0:myexit();return 0;
}
}
}
//void mytest(){
// sqlite3 *db;
// char *errMsg = 0;
// int rc;
// // 打开数据库,如果数据库文件不存在则创建它
// rc = sqlite3_open("./data/msg.db", &db);
// for(int i=1;i<=100;i++){
// char *sql_insert="INSERT INTO tests (test_name,Creater) VALUES (?, 'xianya');";
// sqlite3_stmt *insert;
// char test[10];
// snprintf(test,7,"test%d",i);
// rc = sqlite3_prepare_v2(db, sql_insert, -1, &insert, 0);
// if (rc != SQLITE_OK) {
// sqlite3_close(db);
// return;
// }
//
// // 将第一个参数 (username) 绑定到 SQL 语句中的第一个 "?"
// sqlite3_bind_text(insert, 1, test, -1, SQLITE_STATIC);
//
// rc = sqlite3_step(insert);
// if (rc != SQLITE_DONE) {
// sqlite3_free(errMsg);
// sqlite3_finalize(insert);
// sqlite3_close(db);
// return;
// }
// }
// printf("OK");
// sqlite3_close(db);
// return;
//}