-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_address.c
36 lines (32 loc) · 1.18 KB
/
ft_address.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_address.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ychihab <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/01 15:22:11 by ychihab #+# #+# */
/* Updated: 2022/11/03 10:33:52 by ychihab ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
void ft_p(unsigned long n, int *j)
{
int i;
char *s;
i = 0;
s = "0123456789abcdef";
if (n >= 16)
{
ft_p(n / 16, j);
ft_p(n % 16, j);
}
if (n >= 0 && n <= 15)
ft_putchar(s[n], j);
}
void ft_address(unsigned long n, int *j)
{
write(1, "0x", 2);
*j = *j + 2;
ft_p(n, j);
}