-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_push_nbr.c
35 lines (33 loc) · 1.19 KB
/
ft_push_nbr.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_push_digit.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fokrober <fokrober@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/23 14:55:04 by fokrober #+# #+# */
/* Updated: 2019/05/04 15:29:13 by nkhribec ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_push_nbr(char *s, int n)
{
if (n == MIN_INT)
{
s = ft_push_nbr(s, -214748364);
n = 8;
}
if (n < 0)
{
s = ft_push_char(s, '-');
n *= -1;
}
if (n < 10)
s = ft_push_char(s, '0' + n);
else if (n >= 10)
{
s = ft_push_nbr(s, n / 10);
s = ft_push_nbr(s, n % 10);
}
return (s);
}