A custom implementation of the C printf function, built as a static library.
This project demonstrates variadic functions, format parsing, low-level output handling, and clean Makefile-based builds.
Completed at 42 Berlin (Jan-Feb 2024) as part of the core C curriculum.
This implementation supports the following conversion specifiers:
%c: character%s: string%p: pointer address (0x..., or(nil)for null)%d: signed decimal integer%i: signed decimal integer%u: unsigned decimal integer%x: hexadecimal (lowercase)%X: hexadecimal (uppercase)%%: a literal percent sign
Output artifact:
libftprintf.a(static library)
makeormake all: buildlibftprintf.amake clean: remove object filesmake fclean: remove object files andlibftprintf.amake re: full rebuild (fclean+all)
This library can be compiled on Linux and macOS.
- A C compiler supporting C code used in 42 projects (
cc,gcc, orclang) makear(GNU binutils on Linux, or BSD ar on macOS)- Standard C development headers/toolchain
One common 42 workflow is to add this repository as a ft_printf/ directory inside another project and call its Makefile from your main Makefile.
Example variables in your project Makefile:
FT_PRINTF = ft_printf
LIB_PRINTF = $(FT_PRINTF)/libftprintf.aBuild ft_printf from your project:
$(LIB_PRINTF):
@make -C $(FT_PRINTF)Link your project with ft_printf:
$(NAME): $(OBJ) $(LIB_PRINTF)
$(CC) $(CFLAGS) $(OBJ) $(LIB_PRINTF) -o $(NAME)(c) Maryna Peshko