ft_printf
C project · variadics, libc
printf rebuilt from scratch: chars, strings, pointers, decimals, unsigned and hex.
- 100/100grade
- 9conversions
The problem
Rebuild printf from libc from scratch.
What I built
- All nine conversions: %c %s %p %d %i %u %x %X %%.
- Variadic arguments with stdarg, and number-to-base printing for decimal and hex.
The hard part
Where the va_list lives. The first draft passed it by value to the function that handles each conversion, which works by accident on x86-64 Linux, but on an arm64 Mac each call reads from its own copy: %u %u %u with 1, 2, 3 prints 1 1 1, and %d %s reads the int back as a string pointer and crashes. The handler now takes a pointer, so every conversion moves the same list forward. %p with NULL prints (nil), as glibc does, where macOS prints 0x0.
Built with
- C
- stdarg
- Libft
More projects
- metro · Lisbon metro sim in pixel art: watch the four lines run, step into any station, board a train and ride it.
- pac-man · Pac-Man in Python, built as a duo with sylvzzz: a new maze every level and four ghosts that each hunt you differently.
- call_me_maybe · Turns a sentence into a JSON function call with a 0.6B model using constrained decoding — parseable by construction, not by luck.
- codexion · Multithreaded twist on the Dining Philosophers: coders compete for shared dongles, with FIFO/EDF scheduling.
- dbaltaza.pt · A game-console portfolio where every project is a pre-rendered disc: Vite + TypeScript, no framework, and a paint budget the tests measure.
- fly-in · Drone fleet routing: Dijkstra pathfinding, turn-based scheduling and a pygame replay.
- a-maze-ing · Maze generator with multiple algorithms, pathfinding solvers and terminal visualization.
- push_swap · Highly optimized sorting with two stacks and a tiny set of allowed operations.
- get_next_line · Reads a file descriptor one line at a time with careful dynamic memory handling.
- Libft · My own C standard library — the foundation every later 42 project is built on.