42_minishell/libftx/printf/ft_dprintl_base.c

35 lines
1.2 KiB
C
Raw Normal View History

2023-01-31 08:40:15 -05:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_dprintl_base.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/10 03:26:21 by cchauvet #+# #+# */
2023-02-17 10:33:52 -05:00
/* Updated: 2023/02/17 16:30:25 by cchauvet ### ########.fr */
2023-01-31 08:40:15 -05:00
/* */
/* ************************************************************************** */
#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;
2023-02-17 10:33:52 -05:00
i += ft_putchar_fd_p(fd, '-');
2023-01-31 08:40:15 -05:00
}
else
nb = n;
i += ft_dprintul_base(fd, nb, base);
if (i < 1)
return (-1);
return (i);
}