/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_putnbr.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/07/06 07:24:04 by cacharle #+# #+# */ /* Updated: 2019/07/06 15:09:46 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ #include void ft_putchar(char c) { write(1, &c, 1); } void ft_putnbr(int nb) { int i; int rev_digits[100]; unsigned int nbu; if (nb == 0) { ft_putchar('0'); return ; } nbu = nb; if (nb < 0) { ft_putchar('-'); nbu = -nb; } i = 0; while (nbu > 0) { rev_digits[i] = nbu % 10; nbu /= 10; i++; } while (i > 0) ft_putchar(rev_digits[--i] + '0'); }