-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_printf_putarg.c
More file actions
43 lines (39 loc) · 1.67 KB
/
ft_printf_putarg.c
File metadata and controls
43 lines (39 loc) · 1.67 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
42
43
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf_putarg.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dnakano <dnakano@student.42tokyo.jp> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/10/11 09:04:45 by dnakano #+# #+# */
/* Updated: 2020/10/18 14:25:27 by dnakano ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdarg.h>
#include "libftprintf.h"
static int ft_printf_putarg_put(const char fc, va_list *ap,
t_printf_flags *flags)
{
if (fc == '%')
return (ft_printf_putpercent(flags));
else if (fc == 'd' || fc == 'i' || fc == 'u' || fc == 'x' || fc == 'X')
return (ft_printf_putint(fc, ap, flags));
else if (fc == 'p')
return (ft_printf_putpointer(ap, flags));
else if (fc == 'c')
return (ft_printf_putbyte(ap, flags));
else if (fc == 's')
return (ft_printf_putstr(ap, flags));
return (-1);
}
char *ft_printf_putarg(const char *format, va_list *ap, int *count)
{
int res;
t_printf_flags flags;
format = ft_printf_findflags(format, ap, &flags);
res = ft_printf_putarg_put(*format, ap, &flags);
if (res == -1)
return ((char *)format);
*count += res;
return ((char *)format + 1);
}