-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_putunbr_base.c
26 lines (23 loc) · 1.24 KB
/
ft_putunbr_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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putunbr_base.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ylagtab <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/04 15:47:04 by ylagtab #+# #+# */
/* Updated: 2020/10/15 08:38:26 by ylagtab ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_putunbr_base(unsigned long long n, int base, int is_upper)
{
int ret;
static const char *lower_base = "0123456789abcdef";
static const char *upper_base = "0123456789ABCDEF";
ret = 0;
if (n / base)
ret += ft_putunbr_base(n / base, base, is_upper);
ft_putchar(is_upper ? upper_base[n % base] : lower_base[n % base]);
return (ret + 1);
}