diff --git a/srcs/ft_puthex.c b/srcs/ft_puthex.c new file mode 100644 index 0000000..6958c8c --- /dev/null +++ b/srcs/ft_puthex.c @@ -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; +} \ No newline at end of file