-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_padd_numposi_nega.c
54 lines (49 loc) · 1.79 KB
/
ft_padd_numposi_nega.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
43
44
45
46
47
48
49
50
51
52
53
54
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_padd_numposi_nega.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jraymond <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/02/14 18:05:47 by jraymond #+# #+# */
/* Updated: 2018/02/14 18:59:30 by jraymond ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
void ft_neg_no_minus(t_printf *elem, t_nbcaddpw *nbca, char *numb)
{
char sp;
char zero;
sp = ' ';
zero = '0';
if (!(elem->flags & ZERO))
{
ft_handle_overflow(elem, &sp, nbca->width, 1);
ft_handle_overflow(elem, &numb[0], 1, 1);
}
else
{
ft_handle_overflow(elem, &numb[0], 1, 1);
ft_handle_overflow(elem, &zero, nbca->width, 1);
}
numb++;
ft_handle_overflow(elem, &zero, nbca->preci, 1);
ft_handle_overflow(elem, numb, ft_strlen(numb), 2);
}
void ft_posi_no_minus(t_printf *elem, t_nbcaddpw *nbca, char *numb)
{
char sp;
char zero;
char more;
sp = ' ';
more = '+';
zero = '0';
if (!(elem->flags & ZERO))
ft_handle_overflow(elem, &sp, nbca->width, 1);
else
ft_handle_overflow(elem, &zero, nbca->width, 1);
if (elem->flags & MORE)
ft_handle_overflow(elem, &more, 1, 1);
ft_handle_overflow(elem, &zero, nbca->preci, 1);
ft_handle_overflow(elem, numb, ft_strlen(numb), 2);
}