-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_putnbrhex.c
33 lines (30 loc) · 1.17 KB
/
ft_putnbrhex.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
32
33
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbrhex.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mel-mouh <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/18 19:09:24 by mel-mouh #+# #+# */
/* Updated: 2024/11/20 12:21:45 by mel-mouh ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_putnbr_hex(unsigned long int n, char *hexa)
{
char buffer[16];
int i;
int count;
if (n == 0)
return (write(1, "0", 1));
i = 0;
while (n > 0)
{
buffer[i++] = hexa[n % 16];
n /= 16;
}
count = i;
while (i > 0)
ft_putchar(buffer[--i]);
return (count);
}