The ft_printf project challenges us to create a function that mimics the behaviour of the C standard library's printf()
function,
which prints formatted output to the standard output stream or a user-defined output stream.
To use the ft_printf
function, simply clone the repository to your local machine.
The library comes with a Makefile that includes the following rules:
all
: compiles the libraryre
: recompiles the libraryfclean
: removes all object files and the libraryclean
: removes all object files
To compile the library, run:
make all
This will generate a .a
file that you can link to your C projects.
To use the ft_printf function, include the ft_printf.h
header file in your C source files.
#include "ft_printf.h"
int main(void)
{
ft_printf("Hello, %s!\n", "world");
return (0);
}
It supports the following conversion specifiers:
Specifier | Output |
---|---|
%c |
Character |
%s |
String |
%p |
Pointer address |
%d |
Signed decimal integer |
%i |
Signed decimal integer |
%u |
Unsigned decimal integer |
%x |
Unsigned hexadecimal (lowercase) |
%X |
Unsigned hexadecimal (uppercase) |
The ft_printf function is included in the libft project, which is a library of useful functions that are used in later projects at 42. You can find the libft project here.
The ft_printf function is a powerful tool for printing formatted output to the standard output stream or a user-defined output stream. This project has been added to the libft, which is a library of useful functions used in later projects at 42.