-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_putnbr.c
28 lines (25 loc) · 1.14 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ylagtab <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/04 15:49:11 by ylagtab #+# #+# */
/* Updated: 2020/10/15 08:35:36 by ylagtab ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_putnbr(int n)
{
int ret;
ret = 0;
if (n >= 10 || n <= -10)
ret = ft_putnbr(n / 10);
if (n < 0 && n > -10)
ret += ft_putchar('-');
if (n < 0)
return (ret + ft_putchar('0' + (n % 10) * -1));
else
return (ret + ft_putchar('0' + n % 10));
}