aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_putnbr_fd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ft_putnbr_fd.c')
-rw-r--r--src/ft_putnbr_fd.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/ft_putnbr_fd.c b/src/ft_putnbr_fd.c
new file mode 100644
index 0000000..031f9f6
--- /dev/null
+++ b/src/ft_putnbr_fd.c
@@ -0,0 +1,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);
+}