-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_putbase.c
More file actions
49 lines (44 loc) · 1.3 KB
/
Copy pathft_putbase.c
File metadata and controls
49 lines (44 loc) · 1.3 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putbase.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maceccar <maceccar@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/18 15:39:52 by maceccar #+# #+# */
/* Updated: 2023/12/18 15:39:52 by maceccar ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
static int put16(unsigned int lnb, char *base)
{
int i;
i = 0;
if (lnb > 15)
{
i += put16(lnb / 16, base);
lnb %= 16;
}
if (lnb < 16)
{
i += ft_putchar(base[lnb]);
}
return (i);
}
int ft_putbase(unsigned int nb, char *base)
{
long lnb;
int i;
i = 0;
lnb = nb;
if (lnb > 15)
{
i += put16(lnb / 16, base);
lnb %= 16;
}
if (lnb < 16)
{
i += ft_putchar(base[lnb]);
}
return (i);
}