I'm trying to make a C program in which user is able to add multiple students to the list. The point of that is to create a database of students (without accessing a .txt file, It just has to be able to add students and then search for a specific student by surname in the same run, no saving).
struct student{
int semester;
char major[20];
char name[20];
};
struct person{
int id;
char surname[30];
struct student data;
}stud;
typedef struct person* st[10];
int m=0;
int add(){
printf("Type student's surname\n");
st[m]->surname=getchar(); //that's basically the part in which I need help
m=m+1;
}
While I think I can handle searching, I don't really know how to do the adding part. I want to keep it as simple as possible (I'm a freshman). My intent is to use structure person (with student nested to it) and then whenever the user calls function add they'll be able to add one student (let's say that the max is 10). My idea was to make 10 structures (struct[m]) with m rising each time function add is called, but it seems not to work the way I expected.
How can I make it happen? Any help is much appreciated.