A minimal reimplementation of the C printf function for the 42 cursus.
ft_printf is a student reimplementation of the standard printf function. It provides formatted output for a subset of conversion specifiers and is intended for the 42 school project requirements.
- Supported conversion specifiers (typical for this project):
%c,%s,%p,%d,%i,%u,%x,%X,%%. - Handles signed/unsigned integers and hexadecimal output.
- Small, self-contained implementation using the functions in this repository.
ft_printf.c— entry point / format parserft_printf.h— function prototypes and includesft_putchar.c— write a single characterft_putstr.c— write a stringft_putnbr.c— write signed integersft_putunbr.c— write unsigned integersft_putnbr_base.c— write numbers in arbitrary base (hex handling)ft_strlen.c— helper: string lengthMakefile— build rules (createslibftprintf.a)
If your local tree contains additional helper files, list them here.
This repository includes a Makefile that builds a static library named libftprintf.a.
To build:
makeCommon make targets:
all(default) — buildslibftprintf.abonus— builds with bonus object files (ifBONUSis set in the Makefile)clean— remove object filesfclean— remove object files andlibftprintf.are—fcleanthenall
Note: The provided Makefile in this repo sets NAME = libftprintf.a.
Link the static library into your test program. Example:
# build the library
make
# compile a test program (assumes main.c includes ft_printf.h)
gcc -Wall -Wextra -Werror -L. -lftprintf main.c -o test
# run
./testExample main.c:
#include "ft_printf.h"
int main(void)
{
ft_printf("Hello %s! number: %d hex: %x\n", "world", 42, 42);
return 0;
}- miissa