-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_hexa.c
63 lines (55 loc) · 1.75 KB
/
ft_hexa.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_hexa.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rhiguita <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/10 19:23:22 by rhiguita #+# #+# */
/* Updated: 2024/03/16 23:01:40 by rhiguita ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_hexa_upper(unsigned long n, int *i)
{
unsigned int num;
unsigned int len_b;
char *base;
num = (unsigned int)n;
base = "0123456789ABCDEF";
len_b = ft_strlen(base);
if (num >= 16)
{
ft_hexa_upper(num / len_b, i);
}
ft_putchar_fd(*(base + (num % len_b)), i);
}
void ft_hexa_low(unsigned long n, int *i)
{
unsigned int num;
unsigned int len_b;
char *base;
num = (unsigned int)n;
base = "0123456789abcdef";
len_b = ft_strlen(base);
if (num >= 16)
{
ft_hexa_low(num / len_b, i);
}
ft_putchar_fd(*(base + (num % len_b)), i);
}
/*
// Esta dos funciones se utlizan para imprimir un nummero Hexadecimal.
// sea en Mayusculas o minusculas.
int main(void)
{
int i = 0;
unsigned long num = 255;
printf("UPPERCASE: \n" );
ft_hexa_upper(num, &i);
printf("\n");
printf("lowcase: \n" );
ft_hexa_low(num, &i);
printf("\n");
return (0);
}*/