-
Notifications
You must be signed in to change notification settings - Fork 0
/
argument_case.c
40 lines (36 loc) · 1.55 KB
/
argument_case.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* argument_case.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: vde-vasc <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/13 10:08:48 by vde-vasc #+# #+# */
/* Updated: 2022/07/14 18:18:08 by vde-vasc ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int argument_case(char c, va_list arguments)
{
int count;
if (c == 'c')
return (ft_putchar(va_arg(arguments, int)));
if (c == 's')
return (ft_putstr(va_arg(arguments, char *)));
if (c == 'x')
return (ft_puthexa_case(va_arg(arguments, unsigned int), c));
if ((c == 'd') || (c == 'i'))
return (ft_putnbr(va_arg(arguments, int)));
if (c == 'X')
return (ft_puthexa_case(va_arg(arguments, unsigned int), c));
if (c == 'p')
{
count = ft_putstr("0x");
return (count + ft_puthexa_case(va_arg(arguments, unsigned long), c));
}
if (c == 'u')
return (ft_putunbr(va_arg(arguments, unsigned int)));
if (c == '%')
return (ft_putchar('%'));
return (0);
}