A collection of C programs exploring system fundamentals, pointer arithmetic, state machines, and manual memory management. This repository focuses on understanding how high-level abstractions (like Python's .split() or int()) work under the hood.
Concepts: Finite State Machines (FSM), Buffered I/O, Stream Transducers.
A Unix-style utility that functions as both a wc (Word Count) clone and a stream formatter.
- Uses O(1) memory complexity (processes streams of infinite size).
- Implements a State Machine (IN/OUT) to handle tokenization.
- Delivers real-time statistical analysis.
Concepts: Arrays, Buffers, Two-Pass Processing. A text parser that reads input into a stack-allocated buffer and reformats it to "one word per line."
- Demonstrates the trade-offs of buffer-based processing vs. stream processing.
- Includes overflow protection logic.
Concepts: Symbolic Constants, Manual Integer Parsing, Logic Flow. A logistics pricing tool that calculates costs based on weight tiers.
- Key Feature: Does not use
scanf. Implements a custom loop to parse ASCII input digits into integers manually. - Applies symbolic constants for maintainable business logic (Heavy Fees, Limits).
Concepts: ASCII Arithmetic, Data Representation.
A raw implementation of the standard atoi() function.
- Reads character bytes and mathematically converts them to their integer equivalents.
- Demonstrates how computers understand numbers vs. text.
Concepts: Pointers, Memory Addressing.
Recreating the strlen function using pointer arithmetic.
- Avoids array indexing (
i++). - Directly manipulates memory addresses (
s++) to traverse the string segment.
A low-level exploration of standard library functions. This project recreates the logic of scanf from scratch to understand stream I/O, ASCII conversion, and pointer manipulation.
Instead of using the standard scanf("%d"), I built a custom parser (my_scanf) that:
- Manages the Input Stream: Uses
getchar()to read standard input byte-by-byte. - Handles Whitespace: Manually skips spaces, tabs, and newlines.
- Performs ASCII Math: Converts character data into integer types (e.g.,
'5'->5). - Uses Pointers: Modifies variables in the calling function via memory addresses (Pass-by-Reference).
The core conversion logic uses a standard algorithm:
total = (total * 10) + (char - '0');Compile any file using GCC:
gcc stream_auditor.c -o auditor
./auditor