1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <stdio.h>
#include <stdlib.h>

struct Node {
    int value;
    struct Node* next;
};

void insert_after(struct Node* existing, int value, struct Node** a_head) {
    struct Node* new_node = malloc(sizeof(*new_node));
    new_node -> value = value;
    if( existing == NULL ) {  // empty list
        *a_head = new_node;
        new_node -> next = NULL;
    }
    else {
        new_node -> next = existing -> next;
        existing -> next = new_node;
    }
}

int main(int argc, const char* argv[]) {

    return EXIT_SUCCESS;
}

This content is protected and may not be shared, uploaded, or distributed.    © 2019 Alexander J. Quinn.