A simple C implementation of a singly linked list with basic operations such as creation, insertion, deletion, and display.
- Create a list with an initial value
- Insert at the beginning
- Insert at the end
- Insert at a specific position
- Delete from the beginning
- Delete from the end
- Delete from a specific position
- Display the list contents
headers.h- declarations for the linked list functions and node structureList.c- implementation of the linked list operationsmain.c- sample usage of the linked list
Each node stores one integer value and a pointer to the next node:
+-------------------+
| struct node |
|-------------------|
| int data |
| struct node *next |
+-------------------+
|
v
head --> +--------+ +--------+ +--------+ NULL
| data:10| --> | data:20| --> | data:30| -->
| next | | next | | next |
+--------+ +--------+ +--------+
This pattern matches the implementation in List.c, where each node points to the next node and operations like insert/delete update these links.
Compile and run the program using:
gcc main.c List.c -o program.exe
./program.exeThis project is intended as a beginner-friendly example of linked list operations in C.