-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_putnbr_base.c
32 lines (29 loc) · 1.22 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: aachhoub <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/22 12:34:55 by aachhoub #+# #+# */
/* Updated: 2022/10/22 12:34:56 by aachhoub ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
void ft_putnbr_base(unsigned int nb, char cs, int *index)
{
unsigned int n;
char *hex_base;
n = nb;
if (cs == 'x')
hex_base = "0123456789abcdef";
else
hex_base = "0123456789ABCDEF";
if (nb < 16)
ft_putchar(hex_base[n % 16], index);
else
{
ft_putnbr_base(n / 16, cs, index);
ft_putnbr_base(n % 16, cs, index);
}
}