-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_printint.c
41 lines (36 loc) · 1.33 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
40
41
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printint.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mriant <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/01/18 15:56:29 by mriant #+# #+# */
/* Updated: 2022/02/16 13:31:25 by mriant ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_printint(long long int n, int *result, char *base, int fd)
{
char c;
int len;
len = ft_strlen(base);
if (n / len != 0)
ft_printint(n / len, result, base, fd);
c = base[(n % len)];
*result += ft_putchar_int(c, fd);
}
int ft_putdec(int n, int fd)
{
int result;
long int nb;
result = 0;
nb = n;
if (nb < 0)
{
nb = -nb;
result += ft_putchar_int('-', fd);
}
ft_printint(nb, &result, "0123456789", fd);
return (result);
}