aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_putnbr_fd.c
blob: 031f9f65451da37af22eca450f3071f02f3bd6b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "libft.h"
#include <unistd.h>

void
ft_putnbr_fd (int n, int fd)
{
  char c;
  unsigned int nb;

  if (n < 0)
    {
      write (fd, "-", 1);
      nb = -n;
    }
  else
    nb = n;
  if (nb >= 10)
    ft_putnbr_fd (nb / 10, fd);
  c = '0' + nb % 10;
  write (fd, &c, 1);
}