*This project has been created as part of the 42 curriculum by gvoelkne.* # ft_printf ## Description Reimplementation of the C standard library's `printf` function. This project implements formatted output to stdout, supporting the following format specifiers: - `%c` - single character - `%s` - string - `%d`, `%i` - signed decimal integer - `%u` - unsigned decimal integer - `%x` - unsigned hexadecimal (lowercase) - `%X` - unsigned hexadecimal (uppercase) - `%p` - pointer address - `%%` - literal percent sign ## Instructions ```bash # Build the static library make # Clean object files make clean # Clean object files and library make fclean # Rebuild from scratch make re ``` To use in another project, compile with the library: ```bash cc your_file.c -L. -lftprintf -o your_program ``` ## Algorithm and Data Structures The implementation uses a modular approach: 1. **Main loop** (`ft_printf`): Parses the format string, identifies format specifiers, and dispatches to appropriate handlers. 2. **Variadic arguments** (`va_list`): Uses `stdarg.h` to access variable arguments passed to the function. 3. **Type-specific handlers**: - Character and string output handled directly via `write()` syscalls - Integer types converted to strings using `ft_ntoa` (signed) and `ft_untoa` (unsigned) - Pointers formatted as hexadecimal with `0x` prefix via `ft_putptr` 4. **Helper functions**: Memory-safe utilities (e.g. `ft_calloc`, `ft_strdup`) and string manipulation (e.g. `ft_strlen`, `ft_strlower`) support the core functionality. The design prioritizes clarity and correctness over performance, with each format specifier delegated to a dedicated function. ## Resources - [printf(3) man page](https://man7.org/linux/man-pages/man3/printf.3.html) - [stdarg.h documentation](https://en.cppreference.com/w/c/variadic) - 42 School subject materials on variadic functions - Mistral AI as a mental sparring partner.