42_minishell/libftx/printf/ft_dprintptr.c

28 lines
1.2 KiB
C
Raw Normal View History

2023-01-31 08:40:15 -05:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* 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);
}