A custom implementation of the standard C printf()
function for the 42 school project. This implementation handles a limited set of format specifiers and aims to replicate some of the basic functionality of the original printf()
function.
ft_convert_number.c
: Handles the conversion of numbers to strings based on the specified base and sign.ft_printf.c
: Contains the core implementation of the ft_printf() function.ft_printf.h
: Header file containing the function prototypes and necessary includes.ft_putchar.c
: Implements the ft_putchar() function which writes a single character to the standard output.ft_putstr.c
: Implements the ft_putstr() function which writes a string to the standard output.Makefile
: Makefile for building the ft_printf project.
- Compile the project using the provided Makefile by running
make
. - Include the
ft_printf.h
header file in your project. - Call the
ft_printf()
function with the desired format string and arguments.
#include "ft_printf.h"
int main()
{
ft_printf("Hello, %s! The answer is %d.\n", "world", 42);
return 0;
}
%c
: Character%s
: String%X
: Unsigned hexadecimal integer (uppercase)%x
: Unsigned hexadecimal integer (lowercase)%d
or%i
: Signed decimal integer%u
: Unsigned decimal integer%p
: Pointer address%%
: Literal '%' character
This implementation does not support the full set of features provided by the standard printf()
function, such as field width, precision, or flags. It is intended for educational purposes and as a basic starting point for further development.