-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprint_hex.c
More file actions
44 lines (41 loc) · 1.42 KB
/
print_hex.c
File metadata and controls
44 lines (41 loc) · 1.42 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
35
36
37
38
39
40
41
42
43
44
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* print_hex.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bguzel <bguzel@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/10 20:06:05 by bguzel #+# #+# */
/* Updated: 2022/11/20 16:10:22 by bguzel ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
void norm_killer(unsigned int value, char c, int *count)
{
if (c == 'X')
{
if (value > 9)
print_char((int)value + 55, count);
else
print_char((int)value + 48, count);
}
else
{
if (value > 9)
print_char((int)value + 55 + 32, count);
else
print_char((int)value + 48, count);
}
}
void print_hex(unsigned long value, char c, int *count)
{
if (c != 'p')
value = (unsigned int) value;
if (value >= 16)
{
print_hex(value / 16, c, count);
print_hex(value % 16, c, count);
}
else
norm_killer(value, c, count);
}