This project is part of the 42 curriculum.
The goal is to recreate the C standard library function printf with a limited set of features, while learning about variadic functions and formatted output.
ft_printf writes formatted output to the standard output, similar to the real printf.
- Handles the following conversions:
%c: character%s: string%p: pointer (in hexadecimal)%d/%i: signed decimal integer%u: unsigned decimal integer%x/%X: hexadecimal integer (lowercase / uppercase)%%: literal%
- Supports variable argument lists (
<stdarg.h>). - Returns the number of characters printed.
git clone --recurse-submodules git@github.com:grignetta/42_ft_printf.git printfRun make to compile both libft and ft_printf. This will create a static library called libftprintf.a
Create a simple file (e.g. main.c) that uses ft_printf:
#include "ft_printf.h"
int main(void)
{
ft_printf("Hello %s!\n", "world");
ft_printf("Number: %d, Hex: %x, Pointer: %p\n", 42, 42, (void*)42);
return (0);
}cc main.c libftprintf.a -o my_program