This project has been created as part of the 42 curriculum by ALisonCamelo.
The ft_printf project involves re-coding C's standard printf() library function. The goal is to gain a deep understanding of variadic functions in C (stdarg.h), formatted string parsing, and efficient memory/buffer output management using low-level system calls.
| Specifier | Description | Handled File |
|---|---|---|
%c |
Prints a single character. | ft_putchar.c |
%s |
Prints a string of characters (handles NULL). |
ft_putstr.c |
%p |
Prints a void * pointer argument in hexadecimal format. |
ft_putptr.c |
%d |
Prints a decimal (base 10) number. | ft_putnbr.c |
%i |
Prints an integer in base 10. | ft_putnbr.c |
%u |
Prints an unsigned decimal (base 10) number. | ft_putunbr.c |
%x |
Prints a number in lowercase hexadecimal (base 16). | ft_puthex.c |
%X |
Prints a number in uppercase hexadecimal (base 16). | ft_puthex.c |
%% |
Prints a literal percent sign. | ft_putchar.c |
The project compiles into a static library libftprintf.a using the included Makefile.
makeormake all: Compiles the source files and createslibftprintf.a.make clean: Removes all compiled object (.o) files.make fclean: Removes object files and thelibftprintf.alibrary.make re: Recompiles the entire project from scratch.
- Compile the library:
make
- Include the header in your C code:
#include "ft_printf.h" int main(void) { ft_printf("Hello %s! Address: %p | Hex: %x\n", "Alison", &main, 255); return (0); }
- Compile your program with the library: Bash gcc -Wall -Wextra -Werror main.c -L. -lftprintf -o test_printf ./test_printf