/* ************************************************************************** */ /* */ /* ::: o_ :::::: ::: */ /* print_pointer.c :+: / :+::+: :+: */ /* +:+ > +:++:+ +:+ */ /* By: whaffman +#+ +:+ +#++#++:++#++ */ /* +#+ +#+#+ +#++#+ +#+ \o/ */ /* Created: 2024/10/27 16:26:58 by whaffman #+#+# #+#+# #+# #+# | */ /* Updated: 2024/10/27 16:31:19 by whaffman ### ### ### ### / \ */ /* */ /* ************************************************************************** */ #include #include #include #include "libft.h" #include "ft_printf.h" int print_pointer(va_list args) { long n; size_t len; char *str; int wrote; n = va_arg(args, unsigned long); if (!n) return (write(1, "(nil)", 5)); str = ft_calloc(sizeof(char), 20); if (!str) return (-1); ft_strlcpy(str, "0x", 3); ft_putnbr_base(n, "0123456789abcdef", str); len = ft_strlen(str); wrote = write(1, str, len); free(str); return (wrote); }