lib/ft_printf/ft_putnbrhex_upper_fd.c

22 lines
349 B
C

u32
ft_putnbrhex_upper_fd(u32 v, u32 fd)
{
i32 tmp = 0, count = 0;
char hex[100];
if (v == 0)
return ft_putchar_fd('0', fd);
while (v > 0) {
tmp = v % 16;
if (tmp < 10)
hex[count++] = (tmp + 48);
else
hex[count++] = (tmp + 55);
v = v / 16;
}
tmp = count;
while (--tmp >= 0)
ft_putchar_fd(hex[tmp], fd);
return (count);
}