Recreation of the C standard library printf function, built from scratch as part of the 42 Madrid curriculum.
The goal was to understand variadic functions, format string parsing, and low-level data representation without relying on the original libc implementation.
printf/
├── ft_printf.c # Main function and format parser
├── ft_printf.h # Header file
├── utils.c # Helper functions
└── Makefile
| Specifier | Description |
|---|---|
%c |
Single character |
%s |
String |
%p |
Pointer address in hexadecimal |
%d |
Decimal integer |
%i |
Integer |
%u |
Unsigned decimal integer |
%x |
Hexadecimal (lowercase) |
%X |
Hexadecimal (uppercase) |
%% |
Literal percent sign |
make # compile
make clean # remove object files
make fclean # remove object files and library
make re # full rebuild#include "ft_printf.h"gcc main.c -L. -lftprintf -o programft_printf("Hello, %s! Number: %d\n", "world", 42);
ft_printf("Pointer: %p | Hex: %x\n", ptr, 255);- Variadic functions —
va_list,va_start,va_arg,va_end - Format string parsing
- Base conversion (decimal, hexadecimal)
- Writing modular and reusable C code