42_minishell/libftx/printf/ft_dprintl_base.c
Camille Chauvet 5a102e93a1 init
2023-01-31 14:40:15 +01: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);
}