void insert(int key, int data) { struct item *new, **p; /* create the new item */ new = (struct item *)malloc(sizeof(struct item)); /* (should check for NULL return, but omit for this example) */ new->key = key; new->data = data; /* find the (struct item *) to place it at */ for (p = &head; *p && (*p)->key < key; p = &(*p)->next) ; /* link it in */ new->next = *p; *p = new; } void delete(int key) { struct item **p; /* find the (struct item *) which points to it */ for (p = &head; *p && (*p)->key < key; p = &(*p)->next) ; if (*p && (*p)->key == key) { struct item *old = *p; *p = (*p)->next; free((char *)old); } else { printf("error: %d not found\n", key); } }