42_ft_printf/ft_dprintl_base.c
Camille Chauvet 31feb3fe3c final
2022-10-23 19:01:50 +02:00

35 lines
1.2 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_dprintl_base.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/10 03:26:21 by cchauvet #+# #+# */
/* Updated: 2022/10/21 15:54:31 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_dprintl_base(int fd, long long int n, char *base)
{
int i;
unsigned long nb;
if (base == NULL)
return (-1);
i = 0;
if (n < 0)
{
nb = -n;
i += ft_putchar_fd(fd, '-');
}
else
nb = n;
i += ft_dprintul_base(fd, nb, base);
if (i < 1)
return (-1);
return (i);
}