-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_printf.c
48 lines (43 loc) · 1.47 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mg <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/05/26 13:32:51 by mg #+# #+# */
/* Updated: 2020/06/23 21:59:28 by mg ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
/*
** https://www.gnu.org/software/libc/
** manual/html_node/Calling-Variadics.html#Calling-Variadics
*/
int ft_printf(const char *format, ...)
{
va_list ap;
t_fmt flag;
flag.print_len = 0;
va_start(ap, format);
pf_internal(format, &ap, &flag);
va_end(ap);
return (flag.print_len);
}
void pf_internal(const char *format, va_list *ap, t_fmt *flag)
{
while (*format)
{
if (*format == '%')
{
pf_intialize_format(flag);
format += pf_parse_format(format, ap, flag);
pf_print(ap, flag);
}
else
{
flag->print_len += ft_putchar(*format);
++format;
}
}
}