aboutsummaryrefslogtreecommitdiff
path: root/ft_putnbr_fd.c
diff options
context:
space:
mode:
Diffstat (limited to 'ft_putnbr_fd.c')
-rw-r--r--ft_putnbr_fd.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/ft_putnbr_fd.c b/ft_putnbr_fd.c
new file mode 100644
index 0000000..c49de56
--- /dev/null
+++ b/ft_putnbr_fd.c
@@ -0,0 +1,17 @@
+#include <unistd.h>
+#include "libft.h"
+
+void ft_putnbr_fd(int n, int fd)
+{
+ unsigned int p_n;
+
+ p_n = n;
+ if (n < 0)
+ {
+ ft_putchar_fd('-', fd);
+ p_n = -n;
+ }
+ if (p_n > 9)
+ ft_putnbr_fd(p_n / 10, fd);
+ ft_putchar_fd(p_n % 10 + '0', fd);
+}