42_minishell/libftx/printf/ft_dprintptr.c
Camille Chauvet 67fb6d0533 -m
2023-02-14 07:26:18 +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: 2023/02/03 12:53:45 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_p(fd, "(nil)"));
address = (unsigned long) ptr;
i = 2;
ft_putstr_fd_p(fd, "0x");
i += ft_dprintul_base(fd, address, "0123456789abcdef");
return (i);
}