-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_printf.c
49 lines (45 loc) · 1.46 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: amoussai <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/12/06 15:34:54 by amoussai #+# #+# */
/* Updated: 2019/12/07 08:38:33 by amoussai ### ########.fr */
/* */
/* ************************************************************************** */
#include "libftprintf.h"
void initilize_vars(t_vars *var, int x)
{
if (x)
var->chars = 0;
var->lalign = 0;
var->padd = ' ';
var->len = 0;
var->prec = -1;
var->prefix = 0;
}
int ft_printf(const char *fmt, ...)
{
va_list arg_ptr;
int i;
t_vars var;
i = 0;
initilize_vars(&var, 1);
va_start(arg_ptr, fmt);
while (fmt[i] != '\0')
{
if (fmt[i] != '%')
{
var.chars += print_char(fmt[i++]);
continue ;
}
i++;
search_flags1(fmt, &var, &i);
search_flags2(fmt, &var, &i, &arg_ptr);
verify_speciefier(fmt, &var, &i, &arg_ptr);
}
va_end(arg_ptr);
return (var.chars);
}