-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_format.c
36 lines (33 loc) · 1.5 KB
/
ft_format.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_format.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gabd-el- <gabd-el-@student.42wolfsburg. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/25 18:45:03 by gabd-el- #+# #+# */
/* Updated: 2023/01/29 18:58:33 by gabd-el- ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
#include "libft/libft.h"
int ft_format(va_list ap, const char format)
{
int ret;
ret = 0;
if (format == 's')
ft_printstr(va_arg(ap, char *), &ret);
else if (format == 'c')
ft_printchar(va_arg(ap, int), &ret);
else if (format == 'i' || format == 'd')
ft_printnbr(va_arg(ap, int), &ret);
else if (format == 'x' || format == 'X')
ft_printhex(va_arg(ap, unsigned int), format, &ret);
else if (format == '%')
ft_printpercentage(&ret);
else if (format == 'p')
ft_printptr(va_arg(ap, unsigned long long), &ret);
else if (format == 'u')
ft_printunsigned(va_arg(ap, unsigned int), &ret);
return (ret);
}