summaryrefslogtreecommitdiff
path: root/ft_putunsigned.c
diff options
context:
space:
mode:
authoryctct <yctct>2026-01-28 12:43:28 +0100
committeryctct <yctct>2026-01-28 12:43:28 +0100
commit925989f7e7af67d965e2b501a51068acfe449ab0 (patch)
tree7a83e51d2872f9c97abf3166f883ff8dfcf7e2e0 /ft_putunsigned.c
Add all files, first commit
Diffstat (limited to 'ft_putunsigned.c')
-rw-r--r--ft_putunsigned.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/ft_putunsigned.c b/ft_putunsigned.c
new file mode 100644
index 0000000..8908de0
--- /dev/null
+++ b/ft_putunsigned.c
@@ -0,0 +1,29 @@
+
+#include "ft_printf.h"
+
+int ft_putunsigned(unsigned int nb)
+{
+ char c[11];
+ int i;
+ long int nbl;
+ int counter;
+
+ nbl = nb;
+ counter = 0;
+ if (nbl == 0)
+ counter += write(1, "0", 1);
+ i = 0;
+ while (nbl)
+ {
+ c[i] = (nbl % 10) + 48;
+ nbl = nbl / 10;
+ i++;
+ }
+ while (i > 0)
+ {
+ i--;
+ counter += write(1, &c[i], 1);
+ }
+ c[i] = '\0';
+ return (counter);
+}