-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_putnbr.c
38 lines (35 loc) · 1.22 KB
/
ft_putnbr.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ana-lda- <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/08 18:15:57 by anavolkmann #+# #+# */
/* Updated: 2024/06/26 15:32:57 by ana-lda- ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_putnbr(int nbr, int u)
{
int result;
long int i;
if (!u)
i = nbr;
else
i = (unsigned int) nbr;
result = 0;
if (i < 0)
{
result += ft_putchar('-');
i *= -1;
}
if (i < 10)
result += ft_putchar((i % 10) + 48);
else
{
result += ft_putnbr((i / 10), 0);
result += ft_putnbr((i % 10), 0);
}
return (result);
}