-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_puthex.c
More file actions
34 lines (31 loc) · 1.21 KB
/
Copy pathft_puthex.c
File metadata and controls
34 lines (31 loc) · 1.21 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
34
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_puthex.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: moben-ta <moben-ta@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/12/02 13:20:56 by moben-ta #+# #+# */
/* Updated: 2024/12/05 16:09:35 by moben-ta ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_puthex(unsigned int n, char c)
{
int count;
char *base;
count = 0;
if (n >= 16)
count += ft_puthex(n / 16, c);
if (c == 'x')
{
base = "0123456789abcdef";
count += ft_putchar(base[n % 16]);
}
else if (c == 'X')
{
base = "0123456789ABCDEF";
count += ft_putchar(base[n % 16]);
}
return (count);
}