A complete custom implementation of the C standard printf function for 42 School. Supports all mandatory format specifiers (c s p d i u x X %) and uses a modular helper system. No bonus formatting included.
ft_printf is a custom re-implementation of the standard C function printf.
It prints formatted output to stdout using:
write()- variadic arguments (
va_list,va_start,va_arg,va_end) - internal helper functions
It is a mandatory 42 core project and is widely reused in future projects.
| Format | Meaning |
|---|---|
%c |
Character |
%s |
String |
%p |
Pointer address |
%d |
Integer (signed) |
%i |
Integer (signed) |
%u |
Unsigned integer |
%x |
Hexadecimal (lowercase) |
%X |
Hexadecimal (uppercase) |
%% |
Literal % symbol |
📦 ft_printf/ ├── ft_printf.c ├── ft_helpers.c ├── ft_helpers1.c ├── ft_printf.h ├── Makefile └── README.md
ft_printf.c— main dispatcher and parsing logicft_helpers.c & ft_helpers1.c— conversion & printing utilitiesft_printf.h— prototypes, includes, typedefs
Build the static library:
makeThis will create:
libftprintf.a
Remove object files:
make clean
Remove object files + library:
make fclean
Rebuild from scratch:
make re
🧪 Example Usage
#include "ft_printf.h"
int main(void)
{
ft_printf("Hello %s! Number: %d Hex: %x\n", "World", 42, 42);
return 0;
}
Compile with your library:
cc main.c libftprintf.a
💡 Key Concepts
-
Variadic arguments (stdarg.h)
-
Manual formatting without libc formatting
-
Direct output using write()
-
Type dispatching and conversion
-
No dynamic memory required (except strings if implemented)
🚫 Not Included (as required)
❌ Width ❌ Precision ❌ Flags (-, 0, #, +, space) ❌ Bonus formatting
🧑💻 Author
Emanuel Tchipoque
🔗 LinkedIn: Emanuel Tchipoque