-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_put_ptr.c
42 lines (37 loc) · 1.24 KB
/
ft_put_ptr.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
38
39
40
41
42
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_put_ptr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: azaher <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/31 17:10:27 by azaher #+# #+# */
/* Updated: 2022/10/31 17:22:06 by azaher ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
static int print_adress(unsigned long n)
{
int i;
char *lowbase;
i = 0;
lowbase = "0123456789abcdef";
if (n > 15)
{
i += print_adress(n / 16);
i += print_adress(n % 16);
}
else
{
i += ft_putchar(lowbase[n]);
}
return (i);
}
int ft_put_ptr(unsigned long n)
{
int i;
i = 0;
i += ft_putstr("0x");
i += print_adress(n);
return (i);
}