Untitled
Anonymous
Plain Text
04/28/2024 7:47 AM
459 B
21
Indexable
Never
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