-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_putnbr_base.c
More file actions
34 lines (31 loc) · 1.25 KB
/
ft_putnbr_base.c
File metadata and controls
34 lines (31 loc) · 1.25 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr_base.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: miissa <miissa@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/18 13:53:07 by miissa #+# #+# */
/* Updated: 2025/11/22 09:17:49 by miissa ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_putnbr_base(unsigned long n, char *base)
{
unsigned long base_len;
int count;
if (!base)
return (0);
base_len = ft_strlen(base);
if (base_len < 2)
return (0);
count = 0;
if (n >= base_len)
{
count += ft_putnbr_base(n / base_len, base);
count += ft_putnbr_base(n % base_len, base);
}
else
count += ft_putchar(base[n]);
return (count);
}