-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_putnbr.c
31 lines (28 loc) · 1.13 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jfortin <jfortin@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/24 10:23:50 by jfortin #+# #+# */
/* Updated: 2017/11/29 17:08:47 by jfortin ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_putnbr(int nb)
{
int power;
int tmp;
if ((power = nb < 0 ? -1 : 1) == -1)
ft_putchar('-');
tmp = nb;
while (tmp /= 10)
power *= 10;
while (power)
{
ft_putchar(nb / power + '0');
nb -= (nb / power) * power;
power /= 10;
}
}