A versatile and customizable formatted output function.
The ft_printf project reimplements the standard C printf function.
The goal is to create a function capable of formatting and printing different types of data, supporting multiple conversion specifiers, flags, and modifiers. This project deepens the understanding of variadic functions, parsing, and formatted output.
int ft_printf(const char *, ...);%c– Character%s– String%p– Pointer address%d/%i– Signed integers%u– Unsigned integer%x/%X– Hexadecimal (lowercase/uppercase)%%– Percent sign
-(left align)0(zero padding).(precision)#(alternate form for hex)+(force sign)- space (prepend a space for positive numbers)
Clone the repository and compile the library:
git clone https://github.com/hanmpark/ft_printf.git
cd ft_printf
makeThis will create libftprintf.a which you can link into your projects.
Example usage:
#include "ft_printf.h"
int main(void)
{
int count;
count = ft_printf("Hello %s! Number: %d, Hex: %x\n", "world", 42, 42);
ft_printf("Printed %d characters.\n", count);
return (0);
}Compile with:
gcc main.c -L. -lftprintf -I. -o my_program