-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpf_parse_numeric.c
33 lines (29 loc) · 1.21 KB
/
pf_parse_numeric.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* pf_parse_numeric.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gkhodizo <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/07/20 21:27:12 by gkhodizo #+# #+# */
/* Updated: 2020/08/01 18:48:16 by gkhodizo ### ########.fr */
/* */
/* ************************************************************************** */
/*
** The parse_numberic() sets a numeric value to fmt variable
** found inside the string.
** Retuns number of chars parsed.
*/
#include "ft_printf.h"
int parse_numeric(char *str, size_t *fmt)
{
int i;
char *out;
i = 0;
while (ft_isdigit(str[i]))
++i;
out = ft_strsub(str, 0, i);
*fmt = ft_atoi(out);
ft_strdel(&out);
return (i);
}