-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_printf_putpointer.c
33 lines (30 loc) · 1.61 KB
/
ft_printf_putpointer.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf_putpointer.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dnakano <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/10/12 10:13:09 by dnakano #+# #+# */
/* Updated: 2020/10/18 14:25:19 by dnakano ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdarg.h>
#include "libftprintf.h"
int ft_printf_putpointer(va_list *ap, t_printf_flags *flags)
{
int nbrwidth;
t_ullong pt;
pt = va_arg(*ap, t_ullong);
nbrwidth = 2 + ft_printf_putnbr_unsigned_width_digit(pt, 16, flags);
if (flags->precision >= 0)
flags->flag = flags->flag & ~FLAG_ZEROPADDING;
if (nbrwidth < flags->width && !(flags->flag & FLAG_LEFTADJUST))
ft_printf_putpadding(flags->width - nbrwidth, flags);
ft_putstr_fd("0x", 1);
if (!(pt == 0 && flags->precision == 0))
ft_printf_putnbr_unsigned_base_digit(pt, 16, flags->precision, 0);
if (nbrwidth < flags->width && (flags->flag & FLAG_LEFTADJUST))
ft_printf_putpadding(flags->width - nbrwidth, flags);
return (nbrwidth < flags->width ? flags->width : nbrwidth);
}