-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_putmem.c
38 lines (33 loc) · 1.32 KB
/
ft_putmem.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
38
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putmem.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aarbaoui <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/23 11:35:20 by aarbaoui #+# #+# */
/* Updated: 2022/10/27 17:11:01 by aarbaoui ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
void ft_putmem_hex(unsigned long int nbr, int *len)
{
unsigned long int base_len;
char *base;
base_len = 16;
base = "0123456789abcdef";
if (nbr < base_len)
ft_putchar(base[nbr % base_len], len);
else
{
ft_putmem_hex(nbr / base_len, len);
ft_putmem_hex(nbr % base_len, len);
}
}
void ft_putmem(void *p, int *len)
{
unsigned long int ptr;
ptr = (unsigned long int)p;
ft_putstr("0x", len);
ft_putmem_hex(ptr, len);
}