-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_puthex.c
27 lines (24 loc) · 1.15 KB
/
ft_puthex.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_puthex.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: szerisen <szerisen@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/04 20:25:12 by szerisen #+# #+# */
/* Updated: 2023/01/08 20:25:12 by szerisen ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
void ft_puthex(unsigned int n, char c, size_t *ret, size_t *i)
{
char *hex;
hex = "0123456789abcdef";
if (c == 'X')
hex = "0123456789ABCDEF";
if (n > 15)
ft_puthex(n / 16, c, ret, i);
ft_putchar_fd(hex[n % 16], 1, ret);
if (n < 16)
*i = *i + 1;
}