Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
459 B
2
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;
}
Leave a Comment