This repository was archived by the owner on Jun 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_printf_utils2.c
More file actions
55 lines (48 loc) · 1.51 KB
/
ft_printf_utils2.c
File metadata and controls
55 lines (48 loc) · 1.51 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
45
46
47
48
49
50
51
52
53
54
55
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf_utils2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ctherin <ctherin@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/06/20 18:03:00 by ctherin #+# #+# */
/* Updated: 2022/06/20 18:57:25 by ctherin ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_print_u(unsigned int n)
{
char *str;
size_t len;
str = ft_unsigned_itoa_base(n, "0123456789");
if (!str)
return (0);
len = ft_strlen(str);
write(1, str, len);
free(str);
return (len);
}
int ft_print_lowercase_hex(unsigned int n)
{
char *str;
size_t len;
str = ft_itoa_base(n, "0123456789abcdef");
if (!str)
return (0);
len = ft_strlen(str);
write(1, str, len);
free(str);
return (len);
}
int ft_print_uppercase_hex(unsigned int n)
{
char *str;
size_t len;
str = ft_itoa_base(n, "0123456789ABCDEF");
if (!str)
return (0);
len = ft_strlen(str);
write(1, str, len);
free(str);
return (len);
}