![]() ![]() | structures/list-insert-delete.c - Funktionen insert_after. | Lektion 12 - slide 29 : 36 Program 1 |
/* Insert new_element after the cons-cell ptr_list */ void insert_after(void *new_element, cons_cell *ptr_list){ cons_cell *new_cons_cell, *ptr_after; /* Make a new cons-cell around new_element */ new_cons_cell= cons(new_element,NULL); /* Remember pointer to cons-cell after ptr_list */ ptr_after = tail(ptr_list); /* Chain in the new_cons_cell */ set_tail(ptr_list, new_cons_cell); /* ... and connect to rest of list */ set_tail(new_cons_cell, ptr_after); }