This assignment expands upon your previous assignment. In the previous homework, you may have noticed that only one students array can exist. Imagine a scenario in which you wanted to have two arrays of students. For example, a roster for CSI333 and CSI219. This requires two separate arrays of students.
To fix this problem, below introduces a new structure called Course. A course contains an array of students within it.
typedef struct student_struct
{
char name[16];
float gpa;
int age;
} Student;
typedef struct course_struct
{
char name[16];
Student students[100];
int size;
} Course;
Your task in this assignment is to expand the functions used in the previous homework to work with multiple student arrays (Courses). You will have to use pointers to get this to work correctly. Many of the function prototypes have been changed to use pass by pointer.
Implement the following four functions. Use the implementation from the previous homework as a starting point.
void push(Course *course, Student s);
int findStudent(Course course, char *name);
void insert(Course *course, Student s, int idx);
void destroy(Course *course, int idx);
Notice that the four functions now take a Course or Course Pointer parameter. The findStudent function does not use a Course pointer, since it is read-only and does not need to edit the course structure. The other functions require a course to be a pass-by-pointer, since they edit the course structure.
--- CSI219 Student Roster
Greg, 3.0, 18
Henry, 3.1, 19
Adam, 3.1, 21
Ian, 3.2, 20
Jane, 3.3, 21
--- CSI333 Student Roster
Beth, 3.0, 20
Chris, 2.9, 19
Daphney, 3.7, 20
Erin, 3.5, 18
Fred, 2.8, 19
Chris is located at index 1