42_solong/libftx/printf/ft_dprintptr.c
Camille Chauvet 9e58abcd5c kekw
2022-12-22 17:54:17 +01:00

28 lines
1.2 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_dprintptr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/06 17:41:04 by cchauvet #+# #+# */
/* Updated: 2022/10/12 15:22:40 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_dprintptr(int fd, void *ptr)
{
unsigned long address;
int i;
if (ptr == NULL)
return (ft_putstr_fd(fd, "(nil)"));
address = (unsigned long) ptr;
i = 2;
ft_putstr_fd(fd, "0x");
i += ft_dprintul_base(fd, address, "0123456789abcdef");
return (i);
}