This project has been created as part of the 42 curriculum by kkomurat.
ft_printf is a custom implementation of the C standard printf function.
The goal of this project is to understand variadic functions and formatted output by reimplementing printf from scratch.
make # Compile the library (generates libftprintf.a)
make all # Same as make (explicit target)
make clean # Remove object files (.o)
make fclean # Remove object files and library (libftprintf.a)
make re # Recompile everything from scratch
makeandmake allare equivalent. Running either will compile all source files and generatelibftprintf.a.
To use the library in your project, link it at compile time:
cc main.c libftprintf.a -o my_programAnd include the header in your source files:
#include "ft_printf.h"| Specifier | Description |
|---|---|
%c |
Prints a single character |
%s |
Prints a string (NULL is printed as (null)) |
%p |
Prints a pointer address in hexadecimal (0x...) |
%d |
Prints a decimal integer |
%i |
Prints an integer |
%u |
Prints an unsigned decimal integer |
%x |
Prints a number in lowercase hexadecimal |
%X |
Prints a number in uppercase hexadecimal |
%% |
Prints a literal % character |
ft_printf returns the total number of characters printed, or -1 on error.
- 42 Subject PDF (ft_printf)
- Manual pages (
man <function_name>) - klibc vsnprintf.c source code
- cppreference.com - fprintf reference
AI was used for:
- Debugging issues
- Reviewing code structure
- Help with creating README
All code was written and tested manually.