-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_printf.c
More file actions
41 lines (38 loc) · 1.35 KB
/
ft_printf.c
File metadata and controls
41 lines (38 loc) · 1.35 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
38
39
40
41
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ekamada <ekamada@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/06/04 20:33:25 by ekamada #+# #+# */
/* Updated: 2023/06/09 15:23:10 by ekamada ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_printf(const char *format, ...)
{
va_list args;
int printlen;
va_start(args, format);
printlen = 0;
while (*format)
{
while (*format && *format != '%')
{
printlen += write(1, format, 1);
format++;
}
if (*format == '%')
{
format ++;
if (ft_strchr("cspdiuxX", *format) != NULL)
ft_conversions(&format, args, &printlen);
else
printlen += write(1, format, 1);
format ++;
}
}
va_end(args);
return (printlen);
}