-
Notifications
You must be signed in to change notification settings - Fork 0
/
format_str_parser.c
32 lines (30 loc) · 1.47 KB
/
format_str_parser.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* format_str_parser.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tayeo <tayeo@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/06/28 18:34:31 by tayeo #+# #+# */
/* Updated: 2022/07/08 15:46:04 by tayeo ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int format_str_parser(va_list arg_ptr, char format)
{
if (format == 'c')
return (ft_putchar(va_arg(arg_ptr, int)));
else if (format == 's')
return (ft_putstr(va_arg(arg_ptr, char *)));
else if (format == 'p')
return (put_hex_addr(va_arg(arg_ptr, void *)));
else if (format == 'd' || format == 'i')
return (ft_putnbr(va_arg(arg_ptr, int)));
else if (format == 'u')
return (put_uint(va_arg(arg_ptr, unsigned int)));
else if (format == 'x' || format == 'X')
return (put_hex_int(va_arg(arg_ptr, int), format));
else if (format == '%')
return (ft_putchar('%'));
return (0);
}