-
Notifications
You must be signed in to change notification settings - Fork 0
/
ptr.c
31 lines (28 loc) · 1.14 KB
/
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ptr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aelsiddi <aelsiddi@student.42.ae> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/05 19:57:21 by aelsiddi #+# #+# */
/* Updated: 2022/03/05 22:06:58 by aelsiddi ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int handle_ptr(unsigned long ptr, int c)
{
int len;
char *hex;
hex = "0123456789abcdef";
len = 0;
if (!c)
{
len += write(1, "0x", 2);
c++;
}
if (ptr > 15)
len += handle_ptr(ptr / 16, c);
len += ft_putchar(hex[ptr % 16]);
return (len);
}