-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_putptr_bonus.c
34 lines (31 loc) · 1.28 KB
/
ft_putptr_bonus.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putptr_bonus.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: arsobrei <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/08/29 19:45:11 by arsobrei #+# #+# */
/* Updated: 2023/08/31 11:47:06 by arsobrei ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf_bonus.h"
int ft_putptr(unsigned long number, char *base)
{
int length;
int base_length;
length = 0;
base_length = ft_strlen(base);
if (number == 0)
{
return (ft_putstr("(nil)"));
}
if (number >= (unsigned long)base_length)
{
length += ft_putptr((number / base_length), base);
}
else
length += ft_putstr("0x");
length += ft_putchar(base[number % base_length]);
return (length);
}