-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_puthex.c
More file actions
30 lines (27 loc) · 1.15 KB
/
ft_puthex.c
File metadata and controls
30 lines (27 loc) · 1.15 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_puthex.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: slargo-b <slargo-b@student.42madrid.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/03 12:26:48 by slargo-b #+# #+# */
/* Updated: 2025/02/05 18:31:34 by slargo-b ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_puthex(unsigned long n, char c)
{
int len;
char *base;
len = 0;
if (c == 'x' || c == 'p')
base = "0123456789abcdef";
else
base = "0123456789ABCDEF";
if (n >= 16)
len += ft_puthex(n / 16, c);
ft_putchar(base[n % 16]);
len++;
return (len);
}