ft_printf
Because ft_putnbr() and ft_putstr() aren’t enough
Description
ft_printf is a custom implementation of the standard C library function printf(). This project is designed to replicate its functionality and enhance your understanding of variadic functions in C.
Features
Supported conversions:
%c: Prints a single character
%s: Prints a string
%p: Prints a pointer in hexadecimal format
%d / %i: Prints a signed decimal (base 10) number
%u: Prints an unsigned decimal (base 10) number
%x / %X: Prints a number in hexadecimal format (lowercase/uppercase)
%%: Prints a percent sign
Modular design: Code is structured for readability and extensibility.
Bonus Features
Handles flags like -, 0, . and field width across all conversions.
Supports additional flags: #, +, and space for more customization.
Requirements
Mandatory part:
Write a library (libftprintf.a) with the ft_printf() function.
Use only the following external functions: malloc, free, write, va_start, va_arg, va_copy, and va_end.
Implement all required conversions.
Conform to the 42 Norm and avoid memory leaks.
Bonus part:
Manage flag combinations and advanced formatting features.
The bonus part will only be graded if the mandatory part is perfect.
Installation
Clone the repository and compile the library using the provided Makefile:
bash
cd ft_printf
make
---
### Usage
Include the library in your project and use `ft_printf()` as you would with the standard `printf()`.
Example:
```c
#include "ft_printf.h"
int main(void) {
ft_printf("Hello, %s!\n", "world");
return 0;
}
- Understand the inner workings of
printf()
. - Gain experience working with variadic functions in C.
- Write clean, modular, and extensible code.
This project is part of the 42 curriculum and was developed to enhance system-level programming skills.