/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_putvd.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: erey-bet +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/10/14 23:01:21 by erey-bet #+# #+# */ /* Updated: 2022/10/15 22:15:15 by erey-bet ### ########.fr */ /* */ /* ************************************************************************** */ #include "ft_printf.h" static int ft_putnbrhexull(unsigned long v) { int tmp; int count; count = 0; tmp = 0; while (v > 0) { tmp = v % 16; if (tmp < 10) ft_putchar(tmp + 48); else ft_putchar(tmp + 87); v = v / 16; count++; } return (count); } int ft_putvd(void *v) { int count; unsigned long u; if (v == NULL) return (-2); u = (unsigned long)v; count = 2; ft_putstr("0x"); count += ft_putnbrhexull(u); return (count); }