Linked List Removal
This code removes an entry from an ordered, singly linked list. It follows up on the previous example of a linked list of structures ordered by a key value. The structure is defined the same way:
typedef struct _entry { int key; int data; char name[20]; struct _entry * next; } entry, * entry_ptr;
The head of the linked list is saved in a pointer that is stored outside the list itself. Within the list, the next pointer in each entry points to the next element in the list; the end of the linked list is denoted by a NULL next pointer. Entries with a lower key value appear earlier in the list.
When passed a key value to look ...
Get Find the Bug A Book of Incorrect Programs now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.