-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_printf.c
40 lines (37 loc) · 1.22 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dshatilo <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/06 16:23:19 by dshatilo #+# #+# */
/* Updated: 2023/11/11 08:21:53 by dshatilo ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_printf(const char *str, ...)
{
int len;
int cur_res;
va_list args;
char *s;
va_start(args, str);
len = 0;
s = (char *)str;
while (*s)
{
cur_res = ft_switch(&s, &args);
if (cur_res == -1)
{
va_end(args);
return (-1);
}
if (*s == '%')
s++;
len += cur_res;
s++;
}
va_end(args);
return (len);
}