-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparse_precision.c
34 lines (32 loc) · 1.23 KB
/
parse_precision.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* parse_precision.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: alischyn <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/22 17:11:51 by alischyn #+# #+# */
/* Updated: 2017/03/23 18:54:23 by alischyn ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
const char *parse_precision(t_fmt *fmt, const char *f, va_list ap)
{
if (*f == '.')
{
f++;
fmt->has_precision = true;
fmt->precision = 0;
if (*f == '*')
{
f++;
fmt->precision = va_arg(ap, int);
}
else
{
while ('0' <= *f && *f <= '9')
fmt->precision = fmt->precision * 10 + *(f++) - '0';
}
}
return (f);
}