-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_putnbr_b.c
37 lines (32 loc) · 1.23 KB
/
ft_putnbr_b.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
33
34
35
36
37
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr_b.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aarbaoui <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/23 11:18:56 by aarbaoui #+# #+# */
/* Updated: 2022/10/28 13:06:30 by aarbaoui ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_strlen(char *s)
{
int i;
i = 0;
while (s[i])
i++;
return (i);
}
void ft_putnbr_b(unsigned int nbr, char *base, int *len)
{
unsigned int base_len;
base_len = ft_strlen(base);
if (nbr < base_len)
ft_putchar(base[nbr], len);
else
{
ft_putnbr_b(nbr / base_len, base, len);
ft_putchar(base[nbr % base_len], len);
}
}