-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_putptr.c
34 lines (31 loc) · 1.17 KB
/
ft_putptr.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putptr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbreana <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/10/20 20:02:36 by gbreana #+# #+# */
/* Updated: 2022/01/12 17:37:55 by gbreana ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_putptr(uintptr_t num)
{
int cnt;
cnt = 0;
cnt += ft_putstr("0x");
if (num >= 16)
{
cnt += ft_puthex(num / 16, 'x');
cnt += ft_puthex(num % 16, 'x');
}
else
{
if (num < 10)
cnt += ft_putnbr(num);
else
cnt += ft_putchar(num - 10 + 'a');
}
return (cnt);
}