/42Printf

Printf function recoded, with limited specifiers and flags. Because putnbr and putstr aren’t enough!

Primary LanguageC

Printf42

🔧 C, Makefile
🌍 MacOs

The ft_printf project proposes to recode the printf() function, , with limited specifiers and flags.

It envolves the entire process of parsing, conversions and correct administration of formatting flags. This project allows only the 'write', 'malloc', 'free' and 'exit' functions to be used, as well as the stdarg.h library, requiring that any other necessary function be written by the cadet himself.
It works with variadic functions concept.

Printf function recoded, with limited specifiers and flags. Because putnbr and putstr aren’t enough!

Use:

🚧 project:

42Libft $ make

🚿 Clean Obj files:

42Libft $ make clean

🚿 🚿 Clean All (obj files + binary):

42Libft $ make fclean

🚿 🚿 🚧 Clean All + build:

42Libft $ make re


See Makefile

Logic

Basically, this printf works on demand. It goes through the string and, at each step, prints the character found. (Like a char machine gun - the char found is printed and counted). If printf finds the formatting character '%', it stores the formatting instructions (the flags) in a structure to later format the output according to the stored flags.

Below, a ft_printf's logic:

printf_logic

Var's scope

The function has many variables and each one is used in more than one function. This flowchart helps to understand the variables scope.

Below, a ft_printf's vars scope:

printf_var_scope