#include #include #include #include #include #include "menu.h" #define MAX_INPUT_LENGTH 10 void displayMenu() { printf(" 1.Input\n"); printf(" 2.Output\n"); printf(" 3.Insert\n"); printf(" 4.Delete\n"); printf(" 5.Modify\n"); printf(" 6.Query\n"); printf(" 7.Quit\n"); printf("Please input your option: \n"); } void inputStudentInfo(Student students[], int* count) { int numToInput; char input[10]; printf("Please enter the number of students you want to add: "); if (scanf_s("%d", &numToInput) != 1) { printf("Invalid input, please enter an integer.\n"); return; } if (*count + numToInput > MAX_STUDENTS) { printf("Unable to add more students, maximum capacity has been reached.\n"); return; } for (int i = 0; i < numToInput; i++) { printf("Id: "); scanf_s("%9s", students[*count].id, (unsigned)_countof(students[*count].id)); printf("Class: "); scanf_s("%9s", students[*count].clas, (unsigned)_countof(students[*count].clas)); printf("Name: "); scanf_s("%9s", students[*count].name, (unsigned)_countof(students[*count].name)); printf("Score1: "); scanf_s("%lf", &students[*count].score1); printf("Score2: "); scanf_s("%lf", &students[*count].score2); printf("Score3: "); scanf_s("%lf", &students[*count].score3); students[*count].score = students[*count].score1 + students[*count].score2 + students[*count].score3; (*count)++; start: printf("continue?(yes/no)\n"); scanf_s("%9s", input, (unsigned)_countof(input)); if (strcmp(input, "yes") == 0) { continue; } else if (strcmp(input, "no") == 0) { break; } else { printf("Wrong input,yes or noĦ£\n"); goto start; } } } void displayStudentInfo(Student students[], int count) { for (int i = 0; i < count; i++) { printf("%s %s %s %.1lf %.1lf %.1lf %.1lf\n", students[i].id, students[i].clas, students[i].name, students[i].score1, students[i].score2, students[i].score3, students[i].score); } }