The ft_printf project is a reimplementation of the standard C library function printf()
. This project provides a custom ft_printf()
function, which can be integrated into future projects as part of the custom library libft
.
The ft_printf()
function mimics the behavior of the original printf()
function, supporting multiple conversion specifiers and flags. It handles variable arguments and formats the output based on the specified conversions. The function is designed to be modular and extensible, allowing for easy integration.
- %c: Prints a single character.
- %s: Prints a string.
- %p: Prints a pointer in hexadecimal format.
- %d: Prints a decimal (base 10) integer.
- %i: Prints an integer in base 10.
- %u: Prints an unsigned decimal (base 10) number.
- %x: Prints a number in lowercase hexadecimal (base 16).
- %X: Prints a number in uppercase hexadecimal (base 16).
- %%: Prints a literal '%' character.
- Clone the Repository:
git clone https://github.com/cmunoz-g/printf.git
- Navigate to the Project Directory:
cd printf
- Compile the Library:
make
- Link and Use in Your Code:
Include the header file and link the library in your project:
Compile your project with
#include "ft_printf.h" ... ft_printf("Hello, %s!\n", "world");
libftprintf.a
:gcc main.c -L. -lftprintf -o my_program
- Variadic Functions: The project uses variadic functions (
va_start
,va_arg
, andva_end
) to handle an indefinite number of arguments passed toft_printf()
. - Modular Design: The implementation is broken down into multiple functions for handling different conversions and formatting options, making the code easier to maintain and extend.
- Memory Management: Proper handling of dynamically allocated memory to avoid leaks.