I am looking for a solution at HowTo store data in C. It is not a big deal, where people could say: "just use C++" or kind of something. It is just about storing students information. I know that C# has dictionarys or similar data storing "tools". The question is: HowTo store data in C in the most ethic way?
Here is my code, if you have a general advice, you can share it with me. I am open for everything. Btw I am a beginner at C.
#include
#include
#include
bool running = true;
int userInput;
int listStudent() {
printf("listing students...");
return 0;
}
void addStudent() {
printf("Hello, we are adding Students\n");
return 0;
}
void removeStudent() {
printf("removing Students...\n");
return 0;
}
struct Student {
char firstname[10];
char surname[10];
int age;
int id;
};
struct Methods {
char list[20];
char add[20];
char remove[20];
char search[20];
char exit[20];
};
void showMenuDisplay() {
struct Methods m1;
printf("\nMENU\n");
printf("======\n");
int i;
for (i = 1; i <= 6; i++) {
printf("Method [%d]: %s\n", i, m1.list);
}
printf("Your choice: ");
scanf("%d", &userInput);
switch (userInput) {
case 1:
printf("List Students\n");
//listStudent();
break;
case 2:
printf("Add Student\n");
//addStudent();
break;
case 3:
printf("Remove Student\n");
//removeStudent();
break;
case 4:
printf("Search Student\n");
//searchStudent();
break;
case 5:
printf("Display by class\n");
//displayByClass();
break;
case 6:
running = false;
break;
default:
printf("\nError. Please try again.\n");
}
}
int main(void) {
while(running) {
showMenuDisplay();
}
}