-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_set_flag.c
executable file
·40 lines (38 loc) · 1.46 KB
/
ft_set_flag.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_set_flag.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fflores <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/08/03 10:30:43 by fflores #+# #+# */
/* Updated: 2020/08/03 10:33:52 by fflores ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_set_flag(t_flags *flag, char symbol, t_parameters *prmtrs)
{
if (symbol == '0')
flag->zero_flag = 1;
if (symbol == '-')
flag->negative = 1;
if (symbol == '.')
flag->dot = 1;
if (symbol == '*')
{
if ((flag->dot) == 1)
flag->precision = va_arg(prmtrs->ap, int);
else
flag->width = va_arg(prmtrs->ap, int);
}
if (symbol >= '1' && symbol <= '9')
{
if (flag->dot)
flag->precision =
ft_atoi(&(prmtrs->format_copy[prmtrs->count]), prmtrs);
else
flag->width =
ft_atoi(&(prmtrs->format_copy[prmtrs->count]), prmtrs);
}
return (0);
}