-
Notifications
You must be signed in to change notification settings - Fork 0
/
put_d.c
32 lines (30 loc) · 1.14 KB
/
put_d.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* put_d.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lhanna <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/12/22 17:07:03 by lhanna #+# #+# */
/* Updated: 2021/12/22 17:07:05 by lhanna ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int put_d(int n, int *res)
{
if (n == -2147483648)
put_s("-2147483648", res);
else if (n < 0)
{
put_c('-', res);
put_d(-n, res);
}
else if (n > 9)
{
put_d(n / 10, res);
put_d (n % 10, res);
}
else
put_c(n + 48, res);
return (*res);
}