Since the dawn of civilization, writing has been the ultimate cheat code β a hack for memory, power, and legacy.
The Sumerians carved ideas into clay with reed styluses. They didnβt know it yet, but that was humanityβs first commit.
Public documentation before public repos. Versioning without version control.
Make a mistake? Too bad. No git revert.
Just smash the tablet and start over β literally a rm -rf ./history.
Then time marched on. From clay to papyrus, parchment to Gutenberg, mechanical keyboards to IDEs that autocomplete while you yawn. But the spirit? Still the same. Every letter you type is a negotiation between your brain and the machine. Itβs you saying:
"I command. You execute."
In 1972, Dennis Ritchie stared into the void and said:
βLetβs throw a
printfin here and see what the hell is going on.β
That wasn't just a function. That was a microphone to the soul of the machine. It was the debugger of the heart. It was the first time someone wrote:
printf("Hello, world!\n");β¦and the machine blinked back with a terminal prompt and a binary sigh.
That moment didnβt just birth the C language. It sparked the entire hacker ethos as we know it.
Now itβs your turn.
With ft_printf, you enter the inner circle. But here? No stdio.h. No training wheels.
You're about to carve your own binary typography with bare hands and pointer arithmetic.
No emotional support from standard libraries.
If you want to print "42" on screen, you're going to negotiate directly with write() like itβs a hostage situation.
Youβll finesse pointers like you're picking a digital lock.
Youβll convert integers with raw willpower and caffeine.
And each %x, %p, %d you reimplement is a battle cry in the void saying:
βRelax, Dennis. Iβve got this.β
Today you print logs, status messages, memory addresses, accented strings, angry errors, and proud successes. But everything β and I mean everything β starts with one system call:
write(1, &char, 1);Poetic, isnβt it? Youβre running millions of cycles per second, packing 64GB of RAM, and stillβ¦ when life hits the fan:
printf("wtf is happening\n");β Come on, you know that line has saved you more times than youβd admit in public.
βWhen you understand the difference between
%xand%X, and can handle(null)with grace and compassion, thenβ¦ you may proceed to the next level.β
During the ft_printf project evaluation, I achieved the maximum score of 100%, the result of delivering all mandatory and bonus functionalities with precision, while fully meeting the technical standards required, including:
β
Correct and efficient reimplementation of all standard printf behaviors
β
Handling of complex format specifiers and flags
β
Full compliance with Norminette coding standards
β
Zero memory leaks (Valgrind clean)
β
Implementation of bonus features, such as extended format support and robust edge-case handling
This score demonstrates not only deep understanding of C and formatted output logic, but also a strong commitment to code quality, performance, and low-level programming practices β essential values at the core of the 42 curriculum.
ft_printf is a manual reimplementation of the classic C printf function. Without relying on standard formatting libraries (<stdio.h>), weβre challenged to build a robust system that accepts multiple types, formats strings, converts integers, hexadecimals, and pointers β all while respecting precision, flags, and more.
---
title: Ft_Printf Flow & Logic (Expanded Layout)
---
classDiagram
class Ft_Printf {
+ Iterates through format string
+ Detects '%' specifier
+ Calls print_* functions
}
class va_list {
+ Accesses variadic arguments
+ Uses va_start
+ Uses va_arg
+ Uses va_end
}
class ft_putchar {
+ Prints a single character
}
class ft_putstr {
+ Prints a string or "(null)"
}
class ft_putnumber {
+ Prints signed integer
}
class ft_putunsigned {
+ Prints unsigned integer
}
class ft_puthex {
+ Prints hexadecimal number
+ Supports lowercase (x) and uppercase (X)
}
class ft_putpointer {
+ Prints pointer address in hexadecimal
+ Format: 0x...
}
class write {
+ System call: write()
+ Sends output to stdout
}
%% Connections from ft_printf
Ft_Printf --> va_list
Ft_Printf --> ft_putchar
Ft_Printf --> ft_putstr
Ft_Printf --> ft_putnumber
Ft_Printf --> ft_putunsigned
Ft_Printf --> ft_puthex
Ft_Printf --> ft_putpointer
%% Output handling
ft_print* --> write
While building ft_printf, I'll internalize fundamental low-level concepts that shape every high-performance language:
β
Pointer manipulation and va_list
β
Integer-to-string conversion (base 10, 16, and others)
β
Buffer creation, counters, and flow control
β
Modularization using structs and dispatch tables
β
Full control over text formatting (without using printf!)
β
Handling variadic arguments with stdarg.h
β
Creating specific functions for each format type
β
Converting negative integers without using itoa()
β
Safe pointer printing with fallback to (nil)
β
Accurate character return count (like the real printf)
π¦ ft_printf
β£ π libft
β β£ π ft_memset.c
β β£ π ft_bzero.c
β β£ π ft_strncmp.c
β β π ...
β π ft_printf.c
β π ft_putchar.c
β π ft_putnumber.c
β β π ...
πΉ Manual Conversion β Total Control over Output
%c: prints characters directly%s: handles strings, including NULL safety%d/%i: signed integers%u: unsigned integers%x/%X: hexadecimals (lowercase or uppercase)%p: pointer formatting with0xprefix%%: literal percent symbol
| Concept | Description |
|---|---|
va_list |
Type used to traverse variadic arguments |
va_start |
Initializes the argument list |
va_arg |
Accesses the next argument |
write |
System call to print bytes |
itoa |
Integer-to-string conversion (manual) |
%p |
Pointer converter: prints memory addresses with 0x |
recursion |
Technique used to print numbers without buffer allocation |
# Compile the project
make
# Clean compiled objects
make clean
# Clean all (including .a)
make fclean
# Recompile from scratch
make re
To test your implementation using your own main.c, you can compile it like this:
cc main.c libftprintf.a
πΉ Make sure you have already run make so that libftprintf.a exists.
πΉ The main.c file should include #include "ft_printf.h" to access your functions.
πΉ It is acceptable to ignore warnings during compilation, as they are expected for testing the scope and analyzing the results of the project.
ft_printf is not just a technical exercise β it's a foundation. It teaches how complex systems interpret, translate, and display reality. From server logs to game console messages, every system communicates. And every digital communication begins with a print.
By building yours from scratch, you step into the heart of software engineering.
I'm currently working on a detailed tutorial to help others navigate the FT_PRINTF project more efficiently. This section will include:
πΉ Video Guide β A step-by-step walkthrough explaining key concepts and solutions.
π PDF Guide β A structured document with explanations, tips, and best practices.
Stay tuned! The tutorial will be available soon. π
If you're also doing the Piscine, feel free to suggest improvements or share new approaches!
π¬ Contact: If you'd like to discuss solutions or exchange ideas, find me on Discord or GitHub!

