-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_pnbr.c
35 lines (32 loc) · 1.11 KB
/
ft_pnbr.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_pnbr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aizsak <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/13 10:48:05 by aizsak #+# #+# */
/* Updated: 2022/12/11 10:49:26 by aizsak ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_pnbr(int n)
{
long ln;
int i;
i = 0;
ln = n;
if (ln < 0)
{
i += ft_pchar('-');
ln *= -1;
}
if (ln <= 9)
i += ft_pchar(ln + '0');
else
{
i += ft_pnbr(ln / 10);
i += ft_pnbr(ln % 10);
}
return (i);
}