-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_puthex.c
27 lines (24 loc) · 1.14 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: zelhajou <zelhajou@student.1337.ma> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/10 03:14:47 by zelhajou #+# #+# */
/* Updated: 2022/12/13 05:12:57 by zelhajou ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_puthex(unsigned long nbr, char c)
{
int len;
len = 0;
if (nbr > 15)
len += ft_puthex(nbr / 16, c);
if (c == 'x')
len += write(1, &"0123456789abcdef"[nbr % 16], 1);
else
len += write(1, &"0123456789ABCDEF"[nbr % 16], 1);
return (len);
}