I'm having difficulties using malloc to dynamically allocate memory when creating linked list nodes.
For my assignment, we MUST use the following struct definitions:
typedef struct course {
char *name;
BST students;
} Course;
typedef struct courseNode {
Course data;
struct courseNode *next;
} *CourseList;
The CourseList structs are the actual linked list nodes, while the Course structs contain the name of the course and a binary search tree of students enrolled. You'll notice the struct Course is inside the struct CourseList.
I need to create a new CourseList node, given a string to use as the name field of the inner Course struct, using dynamic allocation based on the length of the string. I've tried all combinations of mallocing the outer and inner structs based on the string's length, but I can't seem to get the name string properly copied into the inner struct. I'm sure there's an easy answer, but I'm not finding it.