diff options
Diffstat (limited to 'ft_putunsigned.c')
| -rw-r--r-- | ft_putunsigned.c | 29 |
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); +} |
