A C project that implements an event stream using singly linked lists.
Perfect for learning dynamic memory, pointer manipulation, and modular C design.
- Add events dynamically with
id,source, andpayload - Print full stream contents
- Search for events by ID
- Delete specific events by ID
- Reverse the stream order
- Fully interactive CLI with memory safety
βββ event.h # Structure and function declarations
βββ event.c # Core logic: add, delete, search, reverse
βββ event_stream.c # Main program with menu UI
βββ Makefile # Easy build
--- Event Stream Menu ---
1. Add Event
2. Print Stream
3. Search Event by ID
4. Delete Event by ID
5. Reverse Stream
6. Exit
Enter your choice: 2
Event Stream:
Event ID: 6, Source: sensor-3, Payload: Temperature: 25Β°C
Event ID: 5, Source: light-2, Payload: Light turned on
Event ID: 3, Source: sensor-2, Payload: Humidity: 46%
Event ID: 2, Source: camera-1, Payload: Motion detected
- GCC compiler (e.g.,
gccorclang) - Make utility (recommended)
To build using the provided Makefile:
makeOr compile manually without Makefile:
gcc -o event_stream event.c event_stream.c./event_streamYou'll see an interactive CLI menu:
--- Event Stream Menu ---
1. Add Event
2. Print Stream
3. Search Event by ID
4. Delete Event by ID
5. Reverse Stream
6. Exit
Enter your choice: _
To remove the compiled executable:
make cleanOr manually:
rm event_stream- β C Structures and Linked Lists
- β Modular Programming with Header Files
- β
Dynamic Memory Allocation (
malloc,free) - β CLI Interaction & Input Handling
- β Pointer Manipulation and Traversal
- β
Clean Code Organization using
Makefile
Aditya Chunduri