ft_printf is a custom implementation of the standard C printf function. This project is part of the core 42 curriculum and helps deepen understanding of variadic functions, formatted output, and low-level manipulation of data in C.
The goal of this project is to recreate a simplified version of the C printf function, supporting various format specifiers and flags. It handles variable argument lists and formatted output using only standard system calls like write().
%c: Character%s: String%p: Pointer address%d/%i: Signed integer%u: Unsigned decimal%x: Lowercase hexadecimal%X: Uppercase hexadecimal%%: A literal percent sign
git clone https://github.com/adil-ech/ft_printf
cd ft_printf
makeThis will create the libftprintf.a static library.
In your C program:
#include "ft_printf.h"Compile with:
gcc main.c -L. -lftprintfEnsure both libftprintf.a and ft_printf.h are available in your working directory.
ft_printf/
├── ft_printf.c # Main logic
├── ft_utils.c # Helper functions
├── ft_hex.c # Hex conversion
├── ft_put.c # Print utils
├── ft_ptr.c # Pointer handling
├── Makefile
└── ft_printf.h # Header file
Implement a simplified version of printf, using:
va_list,va_start,va_arg,va_endfor variadic argumentswrite()for all output- Custom integer-to-string conversions
- Manual parsing of format strings
This README only covers the mandatory part of the project. Bonus features like flags (-, 0), field width, and precision are not included.
This project is part of the 42 Network curriculum and should be used for educational purposes only.
You can read the official 42 printf subject here: 👉 ft_printf Subject PDF
