rt/libft/ft_putnbr.c

35 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 12:42:01 by scebula #+# #+# */
/* Updated: 2015/11/30 01:20:12 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_putnbr(int n)
{
if (n == -2147483648)
ft_putstr("-2147483648");
else
{
if (n < 0)
{
ft_putchar('-');
n = -n;
}
if (n >= 10)
{
ft_putnbr(n / 10);
ft_putnbr(n % 10);
}
else
ft_putchar(n + '0');
}
}