Modules:
Student
    |-- Add Student 
    |-- Delete Student 
    |-- Change Student 
    |-- Student Add Course 
    |-- Student Delete Course 
    |-- View Student 
    |-- View Student Course
    |-- Save Student 
    |-- Student Save Course
Administrator
    |-- Administrator Add Course 
    |-- Administrator Delete Course 
    |-- View Course
    |-- Administrator Save Course

Main:


In fact, the above division of administrators and students is just for you to understand. There is only one entry for system design, and the above modules will appear in the directory of the start page;

It is reasonable to say that no matter the administrator adds(delete) the course or the student adds(delete) the personal information and course, all functions containing the I/O operation should have corresponding options for selection after the functions to save the contents in the buffer into the corresponding file.

Details:

Add Student & "stu" & the Student Linked List & the Function needed
For students, first, you need to add a student node. Here, only the student's name, student number and gender are added, and age and other information are not listed; Stored in a linked list, the student structure "stu" has not only the above information and the student's own structure pointer, but also the structure pointer of course selection information.
Here is the "stu":

typedef struct stu {
    int ID;
    char name[32];
    char sex[10];
    struct cour *selection; // the course selection structure pointer
    struct stu *next; // the student structure pointer
} stu,*pstu; // the Pointer point the "stu"

Next, you need to create a linked list to store student information, new_stu=create_stu(stu_head); Incoming head node, each time allocating a"stu"size of memory space new_stu to store students;The create_student function calls the find_student function to determine if a new student node has been added before, the criterion is ID; if you repeat, re-enter ID, otherwise continue to enter sex.And here comes the step needs to be careful, because student node comes before the Course selection , so the previously defined structure pointer should be NULL at this time, not only to initialize next, but also to initialize selection and return new_stu.
Here is the create_stu function & the find_stu function needed:

pstu create_stu(pstu stu_head) {
    pstu new_stu=(pstu)malloc(sizeof(stu));
    printf("\n");
    printf("---------   Input the Student information   ---------\n");
    printf("\n");
    printf("Input the name:");
    scanf("%s",new_stu->name);
    printf("Input the ID:");
    scanf("%d",&new_stu->ID);
while (find_stu(stu_head,new_stu->ID)!=NULL) {
        printf("This ID has been used,try again.");
        scanf("%d",&new_stu->ID);
    }
    printf("Input the sex:");
    scanf("%s",new_stu->sex);
    new_stu->selection=NULL;
    new_stu->next=NULL;
    return new_stu;
}

The function is called recursively with two end conditions, either return NULL or stu_head

pstu find_stu(pstu stu_head,int ID) {
    if(stu_head==NULL)
        return NULL;
    if(stu_head->ID==ID)
        return stu_head;
    return find_stu(stu_head->next, ID);
}

Then, stu_head=add_stu(stu_head,new_stu); Add Student Information to the Linked List,if the stu_head is NULL,return the new_stu.Otherwise new_Stu as a guard node, the next is stu_head and return the new linked list.

pstu add_stu(pstu stu_head,pstu new_stu) {
    if(stu_head==NULL)
        return new_stu;
    new_stu->next=stu_head;
    return new_stu;
}

Delete Student
Enter the student ID to be deleted in the main function and call find_ stu function finds the node to be deleted through n times recursions as formal parameter of del_stu, calls del_stu function.

printf("Input the ID you want to delete:\n");
scanf("%d",&ID);
stu_head=del_stu(stu_head,find_stu(stu_head,ID));
printf("Delete Success!\n");
pstu del_stu(pstu stu_head,pstu del_point) {
    pstu point;
    if(del_point == NULL) {
        printf("This ID dosen't exist,try again.\n");
        return stu_head;
    }
    point=NULL;
    if(del_point == stu_head ) {
        point=stu_head->next;
        free(stu_head);
        return point;
    }
    point=stu_head;
    while(point) {
        if(point->next == del_point) {
            point->next=del_point->next;
            free(del_point);
            return stu_head;
        }
        point = point->next;
    }
}


Administrator Add Course & the Course Linked List & the Functions needed
Similar to adding students, first create a course linked list and dynamically create a cour size pcour type memory space new_cour, add course name, course ID, teacher name, course hour and course location; Of course, this also requires find_cour to prevent the course ID from not existing.

typedef struct cour {
    char name[20];  //COURSE NAME
    int ID; //COURSE ID
    char teacher[20]; //COURSE TEACHER
    int time; //COURSE HOUR
    int classroom; //COURSE CLASSROOM
    struct cour *next; //COURSE STRUCTURE POINTER
} cour,*pcour; //the Pointer point the Structure cour 
new_cour=creat_cour(cour_head);
cour_head=add_cour(cour_head,new_cour);
pcour find_cour(pcour cour_head,int ID) {
    if(cour_head==NULL)
        return NULL;
    if(cour_head->ID==ID)
        return cour_head;
    return find_cour(cour_head->next, ID);
}
pcour creat_cour(pcour cour_head) {
    pcour new_cour=(pcour)malloc(sizeof(cour));
    printf("\n");
    printf("---------   Input Course Information   ---------\n\n");
    printf("Input Course Name:");
    scanf("%s",new_cour->name);
    printf("Input Course ID:");
    scanf("%d",&new_cour->ID);
while (find_cour(cour_head,new_cour->ID)!=NULL) {
        printf("This ID has existed,try again.");
        scanf("%d",&new_cour->ID);
    }
    printf("Input Teacher's Name:");
    scanf("%s",new_cour->teacher);
    printf("Input Course Time:");
    scanf("%d",&new_cour->time);
    printf("Input Course Location:");
    scanf("%d",&new_cour->classroom);
    new_cour->next=NULL;
    return new_cour;
}

Then, add_cour(pcour cour_head,pcour new_cour) Add Course Information to the Linked List,if the cour_head is NULL,return the new_cour.Otherwise new_cour as a guard node, the next is cour_head and return the new linked list.As same as the function add_stu.

pcour add_cour(pcour cour_head,pcour new_cour) {
    if(cour_head==NULL)
        return new_cour;
    new_cour->next=cour_head;
    return new_cour;
}


Delete Course
As same as the Function del_stu

pcour del_cour(pcour cour_head,pcour del_point) {
    pcour point;
    if(del_point == NULL) {
        printf("This ID dosen't exist,try again.\n");
        return cour_head;
    }
    point=NULL;
    if(del_point == cour_head ) {
        point=cour_head->next;
        free(cour_head);
        return point;
    }
    point=cour_head;
    while(point) {
        if(point->next == del_point) {
            point->next=del_point->next;
            free(del_point);
            return cour_head;
        }
        point = point->next;
    }
}


Student Add Course & View Student & View Course
In order to facilitate course selection, print the basic information of all students before course selection and call out_stu function; Then you can select the student number of the students to be selected and enter the course selection. In fact, the purpose is to associate the students with the courses in the schedule, because the two linked lists are independent at first.

printf("\tStudent Name\tStudent ID\tStudent Sex\n");
out_stu(stu_head);
printf("Input the Student ID:");
scanf("%d",&ID1);
choose_cour(stu_head,ID1,cour_head);

The linked list extraction displays the basic information of all students. Read from the head node, move the head node until it is empty, and stop reading.

void out_stu(pstu stu_head) {
while(stu_head) {
   printf("%s\t\t%d\t\t%s\n",stu_head->name,stu_head->ID,stu_head->sex);
   stu_head=stu_head->next;
   }
}

Operate the cour_head. As same as out_stu.

void out_cour(pcour cour_head) {
    while(cour_head) {     printf("%s\t\t%d\t\t%s\t\t%d\t\t%d\n",cour_head->name,cour_head->ID,cour_head->teacher,cour_head->time,cour_head->classroom);
        cour_head=cour_head->next;
    }
}

If the return value stu_head of the find_stu function is not empty, start the course selection operation. For easy addition, print the optional course information first; pass the return value cour_head of the find_cour function to the point; if not empty, dynamically create a memory space choice_point of type pcour, copy the cour size of the point to the choice_point, and initialize its next pointer.

pstu choose_cour(pstu stu_head,int ID1,pcour cour_head) {
    int ID;
    pcour point=NULL;
    pcour choice_point=NULL;
    pstu stu_point=find_stu(stu_head,ID1);
    if(stu_point!=NULL) {
        printf("\tCourse Name\tCourse ID\tCourse Teacher\tCourse Hour\tCourse Location\n");
        out_cour(cour_head);
        printf("Input the Course ID:");
        scanf("%d",&ID);
        point=find_cour(cour_head,ID);
        if(point!=NULL) {
            choice_point=(pcour)malloc(sizeof(cour));
            memcpy(choice_point,point,sizeof(cour));
            choice_point->next=NULL;
            if(stu_point->selection==NULL) {
                stu_point->selection=choice_point;
            } else {
                choice_point->next=stu_point->selection;
                stu_point->selection=choice_point;
            }
            printf("Choose successfully.\n");
            return stu_head;
        } else {
            printf("This Course ID doesn't exist.\n");
            return stu_head;
        }
    } else {
        printf("This Student ID doesn't exist.");
        return stu_head;
    }
}


View Student Course
This part contains two layers of traversal, the outer loop traverses the student list, and the inner loop traverses the course selection list of each student.

void out_choice(pstu stu_head) {
    pcour point=NULL;
    while(stu_head) {
        point=stu_head->selection;
        printf("\t%s\t\t%d\t\t%s\n",stu_head->name,stu_head->ID,stu_head->sex);
        while(point) {
            printf("\t\t\t\t\t\t\t%s\t\t%d\t\t%s\t\t%d\t\t%d\n",point->name,point->ID,point->teacher,point->time,point->classroom);
            point=point->next;
        }
        stu_head=stu_head->next;
    }
}