42_ft_printf/ft_dprintptr.c

28 lines
1.2 KiB
C
Raw Permalink Normal View History

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