Untitled
unknown
plain_text
2 years ago
459 B
7
Indexable
struct split_list *split(struct node *head) {
struct node *current = head;
struct split_list *list = malloc(sizeof(struct split_list));
list->before = NULL;
list->after = NULL;
struct node *prev = NULL;
while (current->data != 0) {
prev = current;
current = current->next;
}
if (prev != NULL) {
prev -> next = NULL;
list->before = head;
}
list->after = current;
return list;
}Editor is loading...
Leave a Comment