-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_printf.c
56 lines (51 loc) · 1.53 KB
/
ft_printf.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gleonett <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/01/16 17:38:06 by gleonett #+# #+# */
/* Updated: 2019/02/08 08:56:54 by gleonett ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
static void put_fmt(const char *fmt, va_list ap, va_list start)
{
size_t i;
size_t j;
i = 0;
j = i;
while (fmt[i])
{
if (fmt[i] == '%')
{
ft_putnstr_full(fmt + j, (i - j));
parser(ap, start);
i = i + g_mod->i;
i++;
j = i;
g_mod = g_mod->next;
}
else
i++;
}
ft_putstr_full(fmt + j);
}
int ft_printf(const char *fmt, ...)
{
va_list ap;
va_list start;
CH_NULL(fmt);
CH_NULL(g_start_list = init_list());
g_mod = g_start_list;
check_fmt(fmt);
g_output_symbols = 0;
va_start(ap, fmt);
va_copy(start, ap);
put_fmt(fmt, ap, start);
va_end(start);
va_end(ap);
del_list(0);
return (g_output_symbols);
}