Example #1
0
int			ft_printf_hexa(unsigned long n)
{
	if (n >= 16)
		return (ft_printf_hexa(n / 16) + ft_printf_hexa(n % 16));
	else
		return (ft_printf_char(HEX[n]));
}
Example #2
0
int			ft_printf_hexm(unsigned int n)
{
	if (n >= 16)
		return (ft_printf_hexm(n / 16) + ft_printf_hexm(n % 16));
	else
		return (ft_printf_char(ft_toupper(HEX[n])));
}
int		ft_choose_type(va_list ap, const char *format, int *index, t_arg *arg)
{
	if (format[*index] == '%')
	{
		*index = *index + 1;
		return (ft_printf_percent(arg));
	}
	else if (format[*index] == 's')
	{
		*index = *index + 1;
		return (ft_printf_str(ap, arg));
	}
	else if (format[*index] == 'c')
	{
		*index = *index + 1;
		return (ft_printf_char(ap, arg));
	}
	else if (format[*index] == 'x')
	{
		*index = *index + 1;
		return (ft_printf_hexa(ap, arg));
	}
	return (0);
}