-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_putnb_base.c
29 lines (27 loc) · 1.16 KB
/
ft_putnb_base.c
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnb_base.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: thifranc <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/03/12 14:53:24 by thifranc #+# #+# */
/* Updated: 2016/03/31 11:36:58 by thifranc ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_putnb_base(int n, char *base)
{
if (n < 0)
{
ft_putchar('-');
ft_putnb_base(-n, base);
}
else if (0 <= n && (size_t)n < ft_strlen(base))
ft_putchar(base[n]);
else
{
ft_putnb_base(n / ft_strlen(base), base);
ft_putnb_base(n % ft_strlen(base), base);
}
}