-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_check_neg.c
42 lines (39 loc) · 1.33 KB
/
ft_check_neg.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
42
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_check_neg.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ohachim <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/30 14:35:38 by ohachim #+# #+# */
/* Updated: 2019/06/09 19:33:44 by ohachim ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_check_neg(char **bi_fl, char **p_r, int ztrue)
{
char *temp;
char *zro;
if (!ztrue)
{
temp = *p_r;
if (bi_fl[0][0] == '1')
*p_r = ft_strjoin("-", *p_r);
if (bi_fl[0][0] == '1')
free(temp);
}
else
{
free(*p_r);
zro = ft_make_s(1, '0');
temp = zro;
if (bi_fl[0][0] == '1')
zro = ft_strjoin("-", zro);
if (bi_fl[0][0] == '1')
free(temp);
free(*bi_fl);
return (zro);
}
free(*bi_fl);
return (*p_r);
}