-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_printf_dt.c
More file actions
42 lines (39 loc) · 1.64 KB
/
ft_printf_dt.c
File metadata and controls
42 lines (39 loc) · 1.64 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf_dt.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: halhashm <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/16 15:37:08 by halhashm #+# #+# */
/* Updated: 2021/11/17 12:34:02 by halhashm ### ########.fr */
/* */
/* ************************************************************************** */
#include "libftprintf.h"
int ft_printf_dt(const char *c, va_list arg)
{
int i;
i = 0;
if (*c == 'i')
ft_putnbr(va_arg(arg, int), &i);
else if (*c == 'd')
ft_putnbr_base((va_arg(arg, int)), "0123456789", &i);
else if (*c == 'u')
ft_ullitoa_base((va_arg(arg, unsigned int)), "0123456789", &i);
else if (*c == 'c')
ft_putchar(va_arg(arg, int), &i);
else if (*c == 's')
ft_putstr(va_arg(arg, char *), &i);
else if (*c == 'x')
ft_ullitoa_base((va_arg(arg, unsigned int)), "0123456789abcdef", &i);
else if (*c == 'X')
ft_ullitoa_base((va_arg(arg, unsigned int)), "0123456789ABCDEF", &i);
else if (*c == 'p')
{
ft_putstr("0x", &i);
ft_ullitoa_base((va_arg(arg, unsigned long)), "0123456789abcdef", &i);
}
else if (*c == '%')
ft_putchar('%', &i);
return (i);
}