I have a structure that holds another structure, a linked list and a flexible array member. I want to make a shallow copy of this entire structure. What is the fastest way I can do this without loosing any of the components? By this I mean all of the malloced memory for the linked list.
This is the structure I would like copied.
struct Student{
char *name;
int age;
Courses *list; //First course (node) of linked list
Student *friends[]; //Flexible array member
}Student;
Edit: Question mentioned as possible duplicate is for a simple structure and does not mention anything about how to deal with linked lists etx.