-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_putunsigned.c
33 lines (30 loc) · 1.21 KB
/
ft_putunsigned.c
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
30
31
32
33
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putunsigned.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tjkruger <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/03 06:03:54 by tjkruger #+# #+# */
/* Updated: 2024/11/08 12:39:29 by tjkruger ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_putunsigned(unsigned int num, int *chars_pr)
{
char buffer[10];
int i;
if (*chars_pr == -1)
return (-1);
i = 0;
if (num == 0)
return (ft_putchar('0', chars_pr));
while (num > 0)
{
buffer[i++] = (num % 10) + '0';
num /= 10;
}
while (--i >= 0)
ft_putchar(buffer[i], chars_pr);
return (0);
}