-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_ptr.c
48 lines (42 loc) · 1.55 KB
/
ft_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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_ptr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rhiguita <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/10 19:21:21 by rhiguita #+# #+# */
/* Updated: 2024/03/16 22:57:32 by rhiguita ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
static void rec_print(unsigned long n, const char *base, int *i)
{
if (n > (unsigned long)(ft_strlen(base) - 1))
rec_print(n / ft_strlen(base), base, i);
ft_putchar_fd(*(base + (n % ft_strlen(base))), i);
}
void ft_ptr(void *format, int *i)
{
unsigned long n;
const char *base;
n = (unsigned long)format;
base = "0123456789abcdef";
ft_putstr_fd("0x", i);
rec_print(n, base, i);
}
/*
// Imprime un puntero en numero hexadecimal en minusculas.
int main(void)
{
int i = 0;
char *str = "42 MADRID";
int *ptr = &i;
printf("String: \n");
ft_ptr((void *)str, &i);
printf("\n");
printf("Puntero: \n");
ft_ptr((void *)ptr, &i);
printf("\n");
return (0);
}*/