-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_putptr.c
44 lines (39 loc) · 1.34 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
35
36
37
38
39
40
41
42
43
44
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putptr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fmorenil <fmorenil@student.42madrid> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/04 13:55:28 by fmorenil #+# #+# */
/* Updated: 2024/04/08 12:20:38 by fmorenil ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_createptr(unsigned long long ptr)
{
int param;
param = 0;
if (ptr >= 16)
{
param += ft_createptr(ptr / 16);
param += ft_createptr(ptr % 16);
}
else
{
if (ptr <= 9)
param += ft_putchar(ptr + '0');
else
param += ft_putchar(ptr - 10 + 'a');
}
return (param);
}
int ft_putptr(unsigned long long ptr)
{
int param;
param = 0;
param += ft_putchar('0');
param += ft_putchar('x');
param += ft_createptr(ptr);
return (param);
}