-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_printf_ptr.c
35 lines (32 loc) · 1.34 KB
/
ft_printf_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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf_ptr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: arepsa <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/05/16 10:04:26 by arepsa #+# #+# */
/* Updated: 2023/05/16 10:04:30 by arepsa ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
void ft_print_ptr(unsigned long long ptr, char *base, int *count)
{
if (ptr == 0)
ft_putstr_pf("(nil)", count);
else
{
ft_putstr_pf("0x", count);
ft_putnbr_ptr(ptr, base, count);
}
}
void ft_putnbr_ptr(unsigned long long ptr, char *base, int *count)
{
if (ptr < 16)
ft_putchar_pf(base[ptr], count);
if (ptr >= 16)
{
ft_putnbr_ptr(ptr / 16, base, count);
ft_putnbr_ptr(ptr % 16, base, count);
}
}