The most basic dynamic data structure is the linked list. A linked list is the basis for other dynamic structures, such as stacks and queues. A stack conforms to the rules that each new element must be added to the front of the list and that each element can only be removed from the front of the list. A queue conforms to the rules that each new element must be added to the back of the list and that each element can only be removed from the front of the list.
We will implement a simple linked list and then test it from within the main() function. Later, we will employ this list structure and its routines when we return to our carddeck.c program in Chapter 24, Working with Multi-File Programs.
Create a file called linklisttester.c. It is in this single file that we will create our linked list structure, operations, and test code. Before we begin, consider the following diagram of the linked list we will create:
...