-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_put_hexa_base.c
30 lines (27 loc) · 1.21 KB
/
ft_put_hexa_base.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_put_hexa_base.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ael-haib <[email protected] +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/25 03:13:51 by ael-haib #+# #+# */
/* Updated: 2024/03/29 11:20:34 by ael-haib ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_put_hexa_base(unsigned int num, char formatter)
{
int j;
char *base;
base = "";
if (formatter == 'x')
base = "0123456789abcdef";
else if (formatter == 'X')
base = "0123456789ABCDEF";
j = 0;
if (num >= 16)
j += ft_put_hexa_base(num / 16, formatter);
j += ft_putchar(base[num % 16]);
return (j);
}