libft/srcs/ft_putnbr.c

21 lines
367 B
C

#include "libft.h"
#include <unistd.h>
int ft_putnbr(int n)
{
int count = 0;
char c;
if (n == -2147483648)
return write(1, "-2147483648", 11);
if (n < 0)
{
count += ft_putchar('-');
n = -n;
}
if (n >= 10)
count += ft_putnbr(n / 10);
c = '0' + (n % 10);
count += ft_putchar(c);
return count;
}