-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_printf_hex.c
28 lines (26 loc) · 1.24 KB
/
ft_printf_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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf_hex.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rmitache <rmitache@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/05/10 14:39:05 by rmitache #+# #+# */
/* Updated: 2023/05/15 14:13:49 by rmitache ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
void ft_printf_hex(unsigned int input, int *return_value, char format)
{
if (input >= 16)
{
(*return_value)++;
ft_printf_hex(input / 16, return_value, format);
}
if (input < 16)
(*return_value) += 1;
if (format == 'x')
ft_putchar_fd("0123456789abcdef"[input % 16], 1);
if (format == 'X')
ft_putchar_fd("0123456789ABCDEF"[input % 16], 1);
}