資源簡介
C語言學生成績管理系統:使用curses函數庫和MySQL數據庫--源碼
代碼片段和文件信息
#include?“student.h“
void?Add_student(MYSQL?*connection)
{
int i;
int row?=?title_ROW?+?3;
char temp[50];
int number;
char insert[512];
Stu_info?*stu;
stu?=?malloc(sizeof(Stu_info));
title();
mvprintw(MESSAGE_ROW?title_COL?-?20?“the?number?of?student?with?you?want?to?add(q?to?exit):?“);
wgetstr(stdscr?temp);
if?(strcmp(temp?“q“)?==?0)
return;
number?=?atoi(temp);
title();
for?(i?=?0;?i? mvprintw(MESSAGE_ROW?title_COL?-?5?“student?%d:“?i?+?1);
mvprintw(row++?MESSAGE_COL?“?stu_id:?“);
wgetstr(stdscr?temp);
stu->stu_id?=?atoi(temp);
Read_stu_info(stu);
sprintf(insert?“INSERT?INTO?stu_information(stu_id?stu_name?stu_sex?stu_age?chinese?math?english)\
VALUES(%d?‘%s‘?‘%s‘?%d?%f?%f?%f)“?stu->stu_id?stu->name?stu->sex?stu->age?stu->chinese?stu->math?stu->english);
if?(mysql_query(connection?insert))?{
title();
mvprintw(MESSAGE_ROW?MESSAGE_COL?“add?failure:?%s\n“?mysql_error(connection));
refresh();
sleep(1);
return;
}else?{
mvprintw(MESSAGE_ROW?+?10?MESSAGE_COL?“add?success“);
refresh();
sleep(1);
}
refresh();
row?=?title_ROW?+?3;
title();
}
}
- 上一篇:Oracle數據庫教程趙明淵
- 下一篇:最新京東四級地址庫
評論
共有 條評論