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 #+# #+# */
|
2023-02-03 10:02:52 -05:00
|
|
|
/* Updated: 2023/02/03 12:53:45 by cchauvet ### ########.fr */
|
2023-01-31 08:40:15 -05:00
|
|
|
/* */
|
|
|
|
/* ************************************************************************** */
|
|
|
|
|
|
|
|
#include "ft_printf.h"
|
|
|
|
|
|
|
|
int ft_dprintptr(int fd, void *ptr)
|
|
|
|
{
|
|
|
|
unsigned long address;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (ptr == NULL)
|
2023-02-03 10:02:52 -05:00
|
|
|
return (ft_putstr_fd_p(fd, "(nil)"));
|
2023-01-31 08:40:15 -05:00
|
|
|
address = (unsigned long) ptr;
|
|
|
|
i = 2;
|
2023-02-03 10:02:52 -05:00
|
|
|
ft_putstr_fd_p(fd, "0x");
|
2023-01-31 08:40:15 -05:00
|
|
|
i += ft_dprintul_base(fd, address, "0123456789abcdef");
|
|
|
|
return (i);
|
|
|
|
}
|