-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_printf.c
39 lines (36 loc) · 1.21 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: omoudni <omoudni@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/12/09 19:13:19 by omoudni #+# #+# */
/* Updated: 2021/12/11 00:09:24 by omoudni ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_printf(const char *s, ...)
{
va_list args;
int i;
int len;
va_start(args, s);
i = 0;
len = 0;
while (s[i])
{
if (s[i] == '%' && s[i + 1] && ft_in_list(s[i + 1], "cspdiuxX%"))
{
ft_format(s[i + 1], args, &len);
i += 2;
}
else
{
write(1, &s[i], 1);
len++;
i++;
}
}
return (len);
}