-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_dispatch_args.c
More file actions
34 lines (32 loc) · 1.5 KB
/
ft_dispatch_args.c
File metadata and controls
34 lines (32 loc) · 1.5 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_dispatch_args.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ktolba <tolbakevin@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/06/01 17:06:06 by ktolba #+# #+# */
/* Updated: 2025/06/06 16:03:15 by ktolba ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_dispatch_args(va_list args, const char *str)
{
if (*str == 'c')
return (ft_putchar_pf(va_arg(args, int)));
if (*str == 's')
return (ft_putstr_pf(va_arg(args, char *)));
if (*str == 'd' || *str == 'i')
return (ft_putnbr_pf(va_arg(args, int)));
if (*str == 'u')
return (ft_put_unsigned_pf(va_arg(args, unsigned int)));
if (*str == 'x')
return (ft_puthex_pf(va_arg(args, unsigned long), 0));
if (*str == 'X')
return (ft_puthex_pf(va_arg(args, unsigned long), 1));
if (*str == 'p')
return (ft_putptr_pf(va_arg(args, void *)));
if (*str == '%')
return (ft_putchar_pf('%'));
return (0);
}