42_minishell/libftx/printf/ft_dprintptr.c
Camille Chauvet 5a102e93a1 init
2023-01-31 14:40:15 +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);
}