-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_putbase.c
29 lines (26 loc) · 1.2 KB
/
ft_putbase.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putbase.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: llord <llord@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/01/24 15:05:48 by llord #+# #+# */
/* Updated: 2023/03/30 11:46:43 by llord ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
//writes a number in a given base
void ft_putbase(unsigned long n, unsigned long base, char *baselist)
{
char digit;
if (base > ft_strlen(baselist))
write(1, "Unsuitable baselist", 19);
else
{
if (n > base)
ft_putbase((n / base), base, baselist);
digit = baselist[(n % base)];
write(1, &digit, 1);
}
}