summaryrefslogtreecommitdiff
path: root/ft_putunsigned.c
blob: 8908de09fe334bf903ab19c15b7f8dc1c1446f83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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);
}