-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_type.c
37 lines (34 loc) · 1.5 KB
/
ft_type.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_type.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lmery <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/12/08 14:30:40 by lmery #+# #+# */
/* Updated: 2021/12/17 16:35:54 by lmery ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_type(char c, va_list args)
{
int r;
r = 0;
if (c == 'c')
r = ft_putchar_n(va_arg(args, int));
else if (c == 's')
r = ft_putstr_n(va_arg(args, char *));
else if (c == 'p')
r = ft_ub(va_arg(args, unsigned long int), "0123456789abcdef") + 2;
else if (c == 'd' || c == 'i')
r = ft_putnbrbase_n(va_arg(args, int));
else if (c == 'u')
r = ft_putui(va_arg(args, unsigned int));
else if (c == 'x')
r = ft_putx(va_arg(args, unsigned int), "0123456789abcdef");
else if (c == 'X')
r = ft_putx(va_arg(args, unsigned int), "0123456789ABCDEF");
else if (c == '%')
r = ft_putchar_n('%');
return (r);
}