A complete recreation of the standard C
printffunction, a core project at 42.
This project was a deep dive into variadic functions, a powerful but complex feature of C. The main goal was to replicate the functionality of printf from scratch, learning to handle an unknown number of arguments and format types. This project significantly improved my skills in argument parsing, string manipulation, and modular code design.
- Variadic Function: Built around
stdarg.hto process an indefinite number of arguments passed to the function. - Flag Handling: Manages the following conversion specifiers:
%c,%s,%p,%d,%i,%u,%x,%X, and%%. - Challenge: The most challenging part was designing a flexible system to parse the format string and correctly fetch the right argument type from the
va_listwithout errors or memory issues.
-
Clone the repository:
git clone [https://github.com/carlopezc/Printf.git](https://github.com/carlopezc/Printf.git) cd Printf -
Compile the library:
make
This will create the
libftprintf.alibrary file. -
To use it in another program, link the library during compilation:
gcc your_program.c -L. -lftprintf