void according(void) { char option; char sign; system("cls"); switch(language) { case '1' : { printf(" 学生成绩管理系统\n"); printf(" 来自:Dack"); printf("================================================================================\n"); printf("1.显示当前已经记录在册的学生的信息.\n"); printf("2.保存当前注册的学生信息到文件.\n"); printf("3.返回上一层菜单.\n"); printf("4.返回主菜单.\n\n"); } break; case '2' : { printf(" Student achievement management system\n"); printf(" By Dack"); printf("================================================================================\n"); printf("1.Show the current recorded student performance.\n"); printf("2.Save the current student achievement (record to a file).\n"); printf("3.Back to a layer of menu.\n"); printf("4.Back to the main menu.\n\n"); } break; case '3' : { printf(" 生徒の成績管理システム\n"); printf(" 出自:dack"); printf("================================================================================\n"); printf("1.記録によると現在はすでに件数の学生の情報が見られる.\n"); printf("2.保存さしあたって登録した数へのメッセージを文書に署名した.\n"); printf("3.戻ってきてに一层のメニュー.\n"); printf("4.メインメニューに戻る.\n\n"); } break; } do { switch(language) { case '1' : { printf("请输入序号 : "); } break; case '2' : { printf("Please enter the serial number : "); } break; case '3' : { printf("番号を入力してください : "); } break; } fflush(stdin); scanf("%1c",&option); fflush(stdin); if(option<'1'||option>'4'){ switch(language) { case '1' : { printf("错误!你想结束程序吗 ?\n"); printf("请输入 Y 或者 N : "); } break; case '2' : { printf("Error! Do you want finish the program?\n"); printf("Please enter the Y or N : "); } break; case '3' : { printf("誤ったもので、あなたは终わりにプログラムだったのだろうか?\n"); printf("Y あるいは Nで入力してください : "); } break; } scanf("%c",&sign); if(toupper(sign)!='N') exit(0); } }while(option<'1'||option>'4'); fflush(stdin); switch(option) { case '1' : show_student(); break; case '2' : file_saving(); break; case '3' : main_menu(); break; case '4' : main_menu(); break; } switch(language) { case '1' : { printf("你想返回主菜单吗 ?\n"); printf("请输入 Y 或者 N "); } break; case '2' : { printf("Do you want back to main menu ?\n"); printf("Please enter the Y or N "); } break; case '3' : { printf("あなたに戻りたいメインメニューだったのだろうか ?\n"); printf("Y あるいは N で入力してください "); } break; } scanf("%c",&sign); fflush(stdin); if(toupper(sign)!='N'){ system("cls"); main_menu(); } else according(); }
int main(void) { int rval; avro_file_reader_t dbreader; avro_file_writer_t db; avro_schema_t extraction_schema, name_schema, phone_schema; int64_t i; const char *dbname = "student.db"; init(); /*如果student.db存在,则删除*/ unlink(dbname); /*创建数据库文件*/ rval = avro_file_writer_create(dbname, student_schema, &db); if (rval) { fprintf(stderr, "Failed to create %s\n", dbname); exit(EXIT_FAILURE); } /*向数据库文件中添加学生信息*/ add_student(db, "Zhanghua", "Law", "15201161111", 25); add_student(db, "Lili", "Economy", "15201162222", 24); add_student(db,"Wangyu","Information","15201163333", 25); add_student(db, "Zhaoxin", "Art", "15201164444", 23); add_student(db, "Sunqin", "Physics", "15201165555", 25); add_student(db, "Zhouping", "Math", "15201166666", 23); avro_file_writer_close(db); fprintf(stdout, "\nPrint all the records from database\n"); /*读取并输出所有的学生信息*/ avro_file_reader(dbname, &dbreader); for (i = 0; i < id; i++) { if (show_student(dbreader, NULL)) { fprintf(stderr, "Error printing student\n"); exit(EXIT_FAILURE); } } avro_file_reader_close(dbreader); /*输出学生的姓名和电话信息*/ extraction_schema = avro_schema_record("Student", NULL); name_schema = avro_schema_string(); phone_schema = avro_schema_string(); avro_schema_record_field_append(extraction_schema, "Name", name_schema); avro_schema_record_field_append(extraction_schema, "Phone", phone_schema); /*只读取每个学生的姓名和电话*/ fprintf(stdout, "\n\nExtract Name & Phone of the records from database\n"); avro_file_reader(dbname, &dbreader); for (i = 0; i < id; i++) { if (show_student(dbreader, extraction_schema)) { fprintf(stderr, "Error printing student\n"); exit(EXIT_FAILURE); } } avro_file_reader_close(dbreader); avro_schema_decref(name_schema); avro_schema_decref(phone_schema); avro_schema_decref(extraction_schema); /*最后释放学生模式*/ avro_schema_decref(student_schema); return 0; }