-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_print_hex.c
34 lines (31 loc) · 1.21 KB
/
ft_print_hex.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_prin_low_hex.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sbourziq <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/25 16:06:51 by sbourziq #+# #+# */
/* Updated: 2023/11/26 17:57:48 by sbourziq ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
void ft_print_hex(unsigned int low, char str, int *len)
{
char *base;
if (str == 'x')
{
base = "0123456789abcdef";
}
else if (str == 'X')
{
base = "0123456789ABCDEF";
}
if (low >= 16)
{
ft_print_hex(low / 16, str, len);
ft_print_hex(low % 16, str, len);
}
else
ft_putchar(base[low % 16], len);
}