-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_printhex.c
31 lines (28 loc) · 1.18 KB
/
ft_printhex.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printhex.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kchikwam <kchikwam@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/11 19:15:33 by kchikwam #+# #+# */
/* Updated: 2024/07/16 13:35:56 by kchikwam ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_printhex(unsigned long n, int uppercase)
{
char *base;
int count;
count = 0;
if (uppercase)
base = "0123456789ABCDEF";
else
base = "0123456789abcdef";
if (n >= 16)
{
count += ft_printhex(n / 16, uppercase);
}
count += ft_printchar(base[n % 16]);
return (count);
}