-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_putnbr_16.c
32 lines (29 loc) · 1.17 KB
/
ft_putnbr_16.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr_16.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fleitz <fleitz@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/12/15 17:35:23 by fleitz #+# #+# */
/* Updated: 2021/12/16 09:59:37 by fleitz ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_putnbr_16(unsigned int n, char c)
{
char *base;
int i;
int result;
result = 1;
if (c == 'X')
base = "0123456789ABCDEF";
else
base = "0123456789abcdef";
i = n % 16;
n = n / 16;
if (n != 0)
result += ft_putnbr_16(n, c);
write(1, &base[i], 1);
return (result);
}