-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_putptr.c
More file actions
38 lines (35 loc) · 1.34 KB
/
Copy pathft_putptr.c
File metadata and controls
38 lines (35 loc) · 1.34 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
33
34
35
36
37
38
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putptr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: thuynguy <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/29 16:51:06 by thuynguy #+# #+# */
/* Updated: 2022/11/29 19:31:41 by thuynguy ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
void print_ptr(unsigned long ptradd)
{
if (ptradd <= 9)
ft_putchar(ptradd + '0');
else if (ptradd < 16)
ft_putchar(ptradd - 10 + 'a');
else
{
print_ptr(ptradd / 16);
print_ptr(ptradd % 16);
}
}
int ft_putptr(unsigned long ptradd)
{
int ptradd_len;
ptradd_len = 0;
ptradd_len += ft_putstr("0x");
if (ptradd == 0)
return (ptradd_len + ft_putchar('0'));
print_ptr(ptradd);
ptradd_len += print_len_num(ptradd, 16);
return (ptradd_len);
}