-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_putadress.c
More file actions
32 lines (29 loc) · 1.26 KB
/
Copy pathft_putadress.c
File metadata and controls
32 lines (29 loc) · 1.26 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putadress.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tchevrie <tchevrie@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/20 16:41:38 by tchevrie #+# #+# */
/* Updated: 2022/11/08 10:22:22 by tchevrie ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
static size_t printadress(const unsigned long n)
{
if (n / 16)
return (printadress(n / 16) + printadress(n % 16));
else if (!(n / 10))
ft_putchar(n + '0');
else
ft_putchar((char) n - 10 + 'a');
return (1);
}
size_t ft_putadress(void *adress)
{
if (!adress)
return (ft_putstr("(nil)"));
ft_putstr("0x");
return (2 + printadress((unsigned long) adress));
}