blob: 85fb57a503629a8591cda510da23607bda571992 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr_base.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: joelecle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/14 17:07:01 by joelecle #+# #+# */
/* Updated: 2020/02/14 17:07:01 by joelecle ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include <libft.h>
#include <inttypes.h>
void
ft_putnbr_base(long nb, char *base)
{
long i;
uint8_t size;
i = nb;
size = ft_strlen(base);
if (nb < 0)
{
ft_putchar('-');
i = -i;
}
if (i >= size)
{
ft_putnbr_base(i / size, base);
ft_putnbr_base(i % size, base);
}
else
ft_putchar(base[nb]);
}
|