-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_print_ptr.c
37 lines (32 loc) · 1.32 KB
/
ft_print_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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_print_ptr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: awallet <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/23 17:53:42 by awallet #+# #+# */
/* Updated: 2022/08/07 16:35:54 by awallet ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include "ft_printf.h"
static int ft_putptr(unsigned long int n, const char *p, int fd)
{
int len;
len = 0;
if (n >= 16)
len += ft_putptr(n / 16, p, fd);
len += ft_print_putchar_fd(p[n % 16], fd);
return (len);
}
int ft_print_ptr(unsigned long int n, const char *p, int fd)
{
int len;
if (!n)
return (ft_print_putstr_fd(PTR_NULL, 1));
len = 0;
len += ft_print_putstr_fd("0x", 1);
len += ft_putptr(n, p, fd);
return (len);
}