-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_printf.c
More file actions
37 lines (34 loc) · 1.28 KB
/
ft_printf.c
File metadata and controls
37 lines (34 loc) · 1.28 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: vvarodi <vvarodi@student.42madrid.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/08/14 00:03:38 by vvarodi #+# #+# */
/* Updated: 2020/08/15 20:22:45 by vvarodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_printf(const char *s, ...)
{
t_buffer b;
t_flags f;
char *string;
string = (char *)s;
ft_bzero(&b, sizeof(b));
va_start(b.args, s);
while (*string)
{
if (*string == '%')
{
ft_bzero(&f, sizeof(f));
string = read_format(&b, &f, string);
}
else
add_to_buffer(&b, &f, *string++);
}
write(1, b.buffer, b.buff_i);
va_end(b.args);
return (b.buff_i + b.written);
}