My problem is that I need have the potential to store a number of courses each with a name, and in a course is a number of sections, and a number of students in each section each with a name (obviously), and each student has a number of assignments of type float
.
So far I created a nested structure:
struct Student {
float *Assignments;
};
struct Section {
char Student_Name[30];
struct Student *Students;
};
struct Course {
char Course_Name[10];
struct Section *Sections;
};
struct Test_Cases {
struct Course *Courses;
};
Have a pointer to the root structure:
struct Test_Cases *ptr;
And seemingly allocated memory to the root structure and courses with:
ptr = (struct Test_Cases *)malloc(*Num_Cases * sizeof(struct Test_Cases));
ptr->Courses = (struct Course *)malloc(*Num_Courses * sizeof(struct Course));
Is the way I'm going about this correct? Thanks.