-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_putunbr_base_fd.c
26 lines (23 loc) · 1.26 KB
/
ft_putunbr_base_fd.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_fd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ylagtab <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/04 15:47:04 by ylagtab #+# #+# */
/* Updated: 2020/10/14 12:31:38 by ylagtab ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_putunbr_base_fd(unsigned long long n, int base, int is_upper, int fd)
{
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_fd(is_upper ? upper_base[n % base] : lower_base[n % base], fd);
return (ret + 1);
}