Untitled

 avatar
unknown
plain_text
a year ago
459 B
4
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