-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_putnbr_base.c
32 lines (29 loc) · 1.24 KB
/
ft_putnbr_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
30
31
32
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr_base.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ael-khni <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/23 14:08:45 by ael-khni #+# #+# */
/* Updated: 2021/12/21 12:21:57 by ael-khni ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
void ft_putnbr_base(unsigned int nbr, char Xx, int *len)
{
unsigned int base_len;
char *base;
base_len = 16;
if (Xx == 'x')
base = "0123456789abcdef";
else
base = "0123456789ABCDEF";
if (nbr < base_len)
ft_putchar(base[nbr % base_len], len);
else
{
ft_putnbr_base(nbr / base_len, Xx, len);
ft_putnbr_base(nbr % base_len, Xx, len);
}
}