A small C demo project that implements a doubly linked list of int values.
Because this is implemented as a doubly linked list, it can also be used to model other data structures.
For example, it can behave like a stack by adding and removing items from the same end of the list. It can also behave like a queue by adding items to the back and removing them from the front.
The project keeps the API focused on list operations, but those operations are enough to demonstrate how stacks and queues can be built on top of a linked list.
This project is a small personal revisit of an old university assignment.
Years ago, I had to implement a linked list in C as part of a programming paper. I did not do well on it at the time. I had come from writing BASIC and 6510 assembly language on a Commodore 64, so C felt very different, especially pointers and manual memory management.
I never really felt that I understood the assignment properly back then. This project was a chance to come back to it with more experience, slow down, and implement it properly. The goal was not just to make a linked list work, but to understand what the code is doing and write it in a clear, testable way.
list_initlist_insert_firstlist_insert_lastlist_insert_atlist_getlist_remove_firstlist_remove_lastlist_remove_atlist_clearlist_print
makeThis builds the demo app as linked-list.
make runmake testThis builds and runs the unit tests in tests/linked_list_tests.c.
make cleansrc/linked_list.c- linked list implementationsrc/linked_list.h- public APIsrc/main.c- small demo programtests/linked_list_tests.c- unit testsMakefile- build targets
- The list stores
intvalues. - The implementation is currently optimized for clarity rather than maximum performance.
list_printwrites a simple bracketed representation to stdout.