-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflag2.c
34 lines (31 loc) · 1.46 KB
/
flag2.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* flag2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: abello-r <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/03/02 20:08:08 by abello-r #+# #+# */
/* Updated: 2020/03/02 20:08:12 by abello-r ### ########.fr */
/* */
/* ************************************************************************** */
#include "libftprintf.h"
void ft_display_c(t_printf *format, int nb)
{
int space;
int zero;
zero = (format->zero_space == '0' && format->width > 0) ?
format->width - 1 : 0;
space = (format->width > 0) ? (format->width) : 0;
space -= (format->width > 0 && format->tab != '-') ? 1 : 0;
while (zero-- > 0 && format->tab != '-')
{
format->len_str += write(1, "0", 1);
space = 0;
}
while (space-- > 0 && format->tab != '-')
format->len_str += write(1, " ", 1);
format->len_str += write(1, &nb, 1);
while (space-- > 0 && format->tab == '-')
format->len_str += write(1, " ", 1);
}