A re-implementation of the C standard library printf, packaged as a static library. Project of the 42 Common Core.
| Conversion | Output |
|---|---|
%c |
Character |
%s |
String |
%p |
Pointer address in hexadecimal |
%d %i |
Signed decimal integer |
%u |
Unsigned decimal integer |
%x %X |
Hexadecimal (lower / upper case) |
%% |
Percent sign |
Returns the number of characters printed, like the original.
make # builds libftprintf.a
cc main.c libftprintf.a -o demo#include "ft_printf.h"
int main(void)
{
ft_printf("Hello %s, you are %d years old (%p)\n", "Edoardo", 22, &main);
return (0);
}Variadic functions (va_list, va_arg), number base conversion and building reusable static libraries with make and ar.