-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_printint.c
39 lines (34 loc) · 1.29 KB
/
ft_printint.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
34
35
36
37
38
39
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printint.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mriant <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/01/18 15:56:29 by mriant #+# #+# */
/* Updated: 2022/01/19 14:11:59 by mriant ### ########.fr */
/* */
/* ************************************************************************** */
#include "libftprintf.h"
void ft_printint(long long int n, int *result, char *base, int len)
{
char c;
if (n / len != 0)
ft_printint(n / len, result, base, len);
c = base[(n % len)];
*result += ft_putchar_int(c);
}
int ft_putdec(int n)
{
int result;
long int nb;
result = 0;
nb = n;
if (nb < 0)
{
nb = -nb;
result += ft_putchar_int('-');
}
ft_printint(nb, &result, "0123456789", 10);
return (result);
}