-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_putunsigned.c
40 lines (36 loc) · 1.18 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putunsigned.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: amait-ou <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/17 15:19:12 by amait-ou #+# #+# */
/* Updated: 2023/02/07 01:26:13 by amait-ou ### ########.fr */
/* */
/* ************************************************************************** */
#include "./superlib.h"
static int helper(t_ui nb)
{
int i;
i = 0;
if (nb == 0)
++i;
while (nb)
{
++i;
nb /= 10;
}
return (i);
}
int ft_putunsigned(t_ui nb)
{
if (nb >= 0 && nb <= 9)
ft_putchar(nb + 48);
else
{
ft_putunsigned(nb / 10);
ft_putunsigned(nb % 10);
}
return (helper(nb));
}