-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_putptr.c
More file actions
39 lines (35 loc) · 1.29 KB
/
Copy pathft_putptr.c
File metadata and controls
39 lines (35 loc) · 1.29 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putptr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: luis-ffe <luis-ffe@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/12 09:20:12 by luis-ffe #+# #+# */
/* Updated: 2023/10/12 12:29:50 by luis-ffe ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_putptr(unsigned long long num, int fd)
{
int x;
x = 0;
if (num == 0)
return (write (fd, "0", 1));
if (num < 16)
{
return (write (fd, &"0123456789abcdef"[num], 1));
}
else
{
x += ft_putptr(num / 16, fd);
x += ft_putptr(num % 16, fd);
}
return (x);
}
int ft_putptr0x(unsigned long long num, int fd)
{
write (fd, "0", 1);
write (fd, "x", 1);
return ((ft_putptr(num, fd) + 2));
}