-
Notifications
You must be signed in to change notification settings - Fork 0
/
pf_parse_flags.c
37 lines (33 loc) · 1.27 KB
/
pf_parse_flags.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* pf_parse_flags.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gkhodizo <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/07/19 22:12:37 by gkhodizo #+# #+# */
/* Updated: 2020/08/01 18:48:10 by gkhodizo ### ########.fr */
/* */
/* ************************************************************************** */
/*
** The parse_flags() looks for '-' and '0' flags in string, and if one
** is found it sets that flag's var to 1.
** Retuns number of chars parsed.
*/
#include "ft_printf.h"
int parse_flags(char *str, t_fmt *fmt)
{
int i;
i = 0;
while (1)
{
if (str[i] != '-' && str[i] != '0')
break ;
if (str[i] == '-')
fmt->is_minus = 1;
if (str[i] == '0')
fmt->is_zero = 1;
++i;
}
return (i);
}