-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_printutils2.c
55 lines (48 loc) · 1.56 KB
/
ft_printutils2.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printutils2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mhiguera <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/06/02 17:29:38 by mhiguera #+# #+# */
/* Updated: 2023/07/04 17:32:03 by mhiguera ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_printchar(char c)
{
write (1, &c, 1);
return (1);
}
int ft_printunsigned(unsigned int u)
{
int i;
i = 0;
if (u > 9)
i = i + ft_printunsigned(u / 10);
i = i + ft_printchar((u % 10) + '0');
return (i);
}
int ft_printhexalow(unsigned int num)
{
int len;
char *strlow;
strlow = "0123456789abcdef";
len = 0;
if (num >= 16)
len = len + ft_printhexalow(num / 16);
len = len + write(1, strlow + (num % 16), 1);
return (len);
}
int ft_printhexacap(unsigned int num)
{
int len;
char *strcap;
len = 0;
strcap = "0123456789ABCDEF";
if (num >= 16)
len = len + ft_printhexacap(num / 16);
len = len + write(1, strcap + (num % 16), 1);
return (len);
}