-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_put_hexa.c
More file actions
33 lines (30 loc) · 1.29 KB
/
ft_put_hexa.c
File metadata and controls
33 lines (30 loc) · 1.29 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_put_hexa.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tarchimb <tarchimb@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/17 10:24:17 by tarchimb #+# #+# */
/* Updated: 2021/11/18 08:59:39 by tarchimb ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_put_hexa(unsigned long long nb, char c)
{
char *base;
char *base2;
int count;
base = "0123456789abcdef";
base2 = "0123456789ABCDEF";
count = 0;
if (nb > 15)
count = ft_put_hexa(nb / 16, c);
if (nb <= 15 && c == 'p')
count = count + ft_putstr("0x");
if (c == 'X')
count = count + ft_putchar(base2[nb % 16]);
else
count = count + ft_putchar(base[nb % 16]);
return (count);
}