-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_putX.c
45 lines (40 loc) · 1.27 KB
/
ft_putX.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putX.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: vstockma <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/19 14:22:29 by vstockma #+# #+# */
/* Updated: 2022/10/19 14:22:30 by vstockma ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
static void ft_puthexup(unsigned int i)
{
char *arr;
arr = "0123456789ABCDEF";
if (i >= 16)
{
ft_puthexup(i / 16);
ft_puthexup(i % 16);
}
else
ft_putchar(arr[i]);
}
int ft_putxupper(va_list args)
{
int len;
unsigned int i;
len = 0;
i = va_arg(args, unsigned int);
ft_puthexup(i);
if (i == 0)
len++;
while (i > 0)
{
i = i / 16;
len++;
}
return (len);
}