Copy the linked list pointed by a parameter
问题 I'm trying to implement a function which will make a copy of the list pointed by parameter. I store head pointers to nodes in some array and the parameter is just its index. This is my attempt: void copy(node **array, int *amount_of_lists, int parameter) { node *current = array[parameter]; array[(*amount_of_lists) - 1] = malloc(sizeof(node)); node *new_list = array[(*amount_of_lists) - 1]; while(current->next != NULL) { new_list->next = malloc(sizeof(node)); new_list->str = current->str;