51 lines
1.4 KiB
C
51 lines
1.4 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_putvd.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* 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;
|
|
char hex[100];
|
|
|
|
count = 0;
|
|
tmp = 0;
|
|
while (v != 0)
|
|
{
|
|
tmp = v % 16;
|
|
if (tmp < 10)
|
|
hex[count++] = tmp + 48;
|
|
else
|
|
hex[count++] = tmp + 87;
|
|
v = v / 16;
|
|
}
|
|
tmp = count - 1;
|
|
while (tmp >= 0)
|
|
ft_putchar(hex[tmp--]);
|
|
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);
|
|
}
|