A custom implementation of the standard C printf function, developed as part of the 42 Network curriculum.
This project recreates formatted output handling, variadic arguments, and type conversions without relying on the original printf.
- Handles mandatory conversion specifiers:
- %c → character
- %s → string
- %d / %i → signed integer
- %u → unsigned integer
- %x / %X → hexadecimal (lowercase / uppercase)
- %p → pointer address
- %% → literal
%
- Variadic argument handling with
va_start,va_arg, andva_end - Returns the number of characters printed (like the original
printf) - Norminette compliant and memory‑safe
. ├── ft_printf.c # Core implementation ├── ft_printf.h # Header file ├── ft_process_format.c# Format specifier handling ├── utils/ # Helper functions (string, number printing, etc.) └── Makefile # Build rules
make
## 🚀 Usage
```C
#include "ft_printf.h"
int main(void)
{
ft_printf("Hello %s! Number: %d, Hex: %x\n", "world", 42, 42);
return 0;
}gcc main.c libftprintf.a -o test
./testOutput:
Hello world! Number: 42, Hex: 2a
Compare against the original printf:
ft_printf("FT: %d %d %d %%\n", 1, 2, 3);
printf("OG: %d %d %d %%\n", 1, 2, 3);Expected output:
FT: 1 2 3 %
OG: 1 2 3 %