Variadic arguments are usefull!
Summary: The goal of this project is pretty straightforward. Recode printf(). You will mainly learn about using a variable number of arguments. How cool is that?? It is actually pretty cool :)
- format specifiers -
cspdiuxX%
Functions in ft_printf.c
-
ft_printf
(and auxiliary static functions) - Initialization function: start/end variadic arguments functions<stdarg.h>
; in between that, goes through the input string printing plain characters or collecting + treating format specifiers to the print_specified function, thus printing each occurrance with the corresponding function. -
print_specified
- Verifies each format specifier and calls functions in accordance with the collected format specifiers.
The following functions output the input variable (collected by va_arg
function) as a pointer to a string to be printed by the print_specified
function.
Functions in print_alpha.c
ft_putchar
- character (%c
) type input variable;ft_putstr
- string (%s
) type input variable;
Functions in print_numeric.c
ft_putnbr
- int (%i
and%d
) type input variables;ft_puthexa
- lower (%x
) and upper hexadecimal (%X
) type input variables;ft_putunbr
- unsigned int (%u
) type input variables;ft_putptr
- pointer (%p
) type input variable.