Files
ft_printf/libftprintf/ft_vprintf_pointer.c

40 lines
1.3 KiB
C
Raw Normal View History

2022-04-13 08:01:46 +02:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_vprintf_pointer.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni@student.42lausanne.ch +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/01/20 11:56:16 by gbaconni #+# #+# */
/* Updated: 2022/04/15 20:54:31 by gbaconni ### lausanne.ch */
2022-04-13 08:01:46 +02:00
/* */
/* ************************************************************************** */
#include "libftprintf.h"
int ft_vprintf_pointer(const char *format, va_list ap)
{
int ret;
int len;
void *p;
char *s;
2022-04-13 08:01:46 +02:00
(void) format;
ret = 0;
len = 0;
p = va_arg(ap, void *);
if (p == NULL)
{
len = ft_strlen(NIL);
write(1, NIL, len);
return (len);
}
s = ft_ltoa_base((long) p, "0123456789abcdef");
len = ft_strlen(s);
write(1, "0x", 2);
write(1, s, len);
ret += len + 2;
free(s);
return (ret);
2022-04-13 08:01:46 +02:00
}