-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_putunsigned.c
More file actions
48 lines (43 loc) · 1.32 KB
/
Copy pathft_putunsigned.c
File metadata and controls
48 lines (43 loc) · 1.32 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putunsigned.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: luis-ffe <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/12 09:25:05 by luis-ffe #+# #+# */
/* Updated: 2023/10/12 12:28:40 by luis-ffe ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
char *ft_uitoa(unsigned int n)
{
char *num;
int len;
len = ft_num_len(n);
num = (char *)malloc(sizeof(char) * (len + 1));
if (!num)
{
free(num);
return (0);
}
if (n == 0)
num[0] = '0';
num[len] = '\0';
while (n)
{
num[--len] = n % 10 + 48;
n = n / 10;
}
return (num);
}
int ft_putunsignd_fd(unsigned int n, int fd)
{
char *s;
int x;
x = 0;
s = ft_uitoa(n);
x = ft_putstr_fd(s, fd);
free(s);
return (x);
}