feat: added ft_puthex

This commit is contained in:
Zoëy Noort 2025-05-11 19:23:01 +02:00
parent 2bee25020c
commit 9bf197acbd

12
srcs/ft_puthex.c Normal file
View file

@ -0,0 +1,12 @@
#include "libft.h" // for ft_putchar
int ft_puthex(unsigned int n, int uppercase)
{
int count = 0;
char *digits = uppercase ? "0123456789ABCDEF" : "0123456789abcdef";
if (n >= 16)
count += ft_puthex(n / 16, uppercase);
count += ft_putchar(digits[n % 16]);
return count;
}