-
Notifications
You must be signed in to change notification settings - Fork 0
/
fill_with_zero.c
42 lines (39 loc) · 1.37 KB
/
fill_with_zero.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* fill_with_zero.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: monoue <marvin@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/08/06 16:08:33 by monoue #+# #+# */
/* Updated: 2020/08/24 10:13:24 by monoue ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
void fill_output_with_zero(char **str, int margin)
{
while (margin)
{
*str = ft_strjoin_free_both(ft_ctoa_malloc('0'), *str);
margin--;
}
}
void fill_empty_with_zero(char **str, int margin, t_format_info *info)
{
if (info->minus == true && info->precision == NOT_SET)
{
while (margin)
{
*str = ft_strjoin_free_both(*str, ft_ctoa_malloc('0'));
margin--;
}
}
else
{
while (margin)
{
*str = ft_strjoin_free_both(ft_ctoa_malloc('0'), *str);
margin--;
}
}
}