This repository was archived by the owner on Aug 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_argshandle.c
40 lines (37 loc) · 1.62 KB
/
ft_argshandle.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
40
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_argshandle.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ahector <ahector@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/10/30 19:56:46 by ahector #+# #+# */
/* Updated: 2021/12/20 18:08:52 by ahector ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_argshandle(const char *str, va_list ap)
{
int counter;
counter = 0;
if (*str == 'c')
counter += ft_putchar_fd(va_arg(ap, int), 1);
else if (*str == 's')
counter += ft_putstr_fd(va_arg(ap, char *), 1);
else if (*str == 'x')
counter += ft_puthex(va_arg(ap, unsigned int), 1, 0);
else if (*str == 'X')
counter += ft_puthex(va_arg(ap, unsigned int), 1, 1);
else if (*str == 'p')
{
counter += ft_putstr_fd("0x", 1);
counter += ft_putpnbr_fd(va_arg(ap, unsigned long int), 1);
}
else if (*str == '%')
counter += ft_putchar_fd('%', 1);
else if (*str == 'd' || *str == 'i')
counter += ft_putnbr_fd(va_arg(ap, int), 1);
else if (*str == 'u')
counter += ft_putunbr_fd(va_arg(ap, unsigned int), 1);
return (counter);
}