/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_print_x.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: narnaud +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/10/27 09:54:24 by narnaud #+# #+# */ /* Updated: 2021/11/17 10:24:24 by narnaud ### ########.fr */ /* */ /* ************************************************************************** */ #include "ft_printf.h" void ft_print_x(unsigned int n, t_opts *opts) { char *raw; char *nbr; char *tmp; raw = ft_itox((unsigned long int)n, "0123456789abcdef"); if (opts->hash && n != 0) { tmp = raw; raw = ft_strjoin("0x", raw); free(tmp); } nbr = uint_opts_transform(n, raw, opts); opts->dot = 0; ft_print_str(nbr, opts); free(raw); free(nbr); } void ft_print_x_cap(unsigned int n, t_opts *opts) { char *raw; char *tmp; char *nbr; raw = ft_itox((unsigned long int)n, "0123456789ABCDEF"); if (opts->hash && n != 0) { tmp = raw; raw = ft_strjoin("0X", raw); free(tmp); } nbr = uint_opts_transform(n, raw, opts); opts->dot = 0; ft_print_str(nbr, opts); free(raw); free(nbr); } void va_print_x(va_list va_uint, const char *str, t_opts *opts) { (void)*str; ft_print_x(va_arg(va_uint, unsigned int), opts); } void va_print_x_cap(va_list va_uint, const char *str, t_opts *opts) { (void)*str; ft_print_x_cap(va_arg(va_uint, unsigned int), opts); }