-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_putunsigned.c
43 lines (38 loc) · 1.19 KB
/
ft_putunsigned.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putunsigned.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mel-mouh <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/18 19:37:27 by mel-mouh #+# #+# */
/* Updated: 2024/11/19 22:29:42 by mel-mouh ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
static int leen(unsigned int n)
{
int i;
i = 0;
while (n > 0)
{
n /= 10;
i++;
}
return (i);
}
int ft_putunsigned(unsigned int n)
{
int i;
i = leen(n);
if (n == 0)
i += 1;
if (n > 9)
{
ft_putunsigned(n / 10);
ft_putchar((n % 10) + '0');
}
else
ft_putchar(n + '0');
return (i);
}