Example #1
0
int		ft_form2(t_format *tmp, va_list ap)
{
	if (tmp->type == 's')
		return (ft_string(tmp, ap));
	else if (tmp->type == 'C' || (tmp->type == 'c' &&
				ft_strcmp(tmp->lenght, "l") == 0))
		return (ft_wint(tmp, ap));
	else if (tmp->type == 'c')
		return (ft_char(tmp, ap));
	else if (tmp->type == 'd' || tmp->type == 'i' || tmp->type == 'D')
		return (ft_int(tmp, ap));
	else if (tmp->type == 'f' || tmp->type == 'F')
		return (ft_float(tmp, ap));
	else if (tmp->type == 'u' || tmp->type == 'U')
		return (ft_unint(tmp, ap));
	else if (tmp->type == 'o' || tmp->type == 'O')
		return (ft_octal(tmp, ap));
	else if (tmp->type == 'b' || tmp->type == 'B')
		return (ft_binaire(tmp, ap));
	else if (tmp->type == 'e' || tmp->type == 'E')
		return (ft_scienti(tmp, ap));
	else if (tmp->type == 'x' || tmp->type == 'X')
		return (ft_hexa(tmp, ap));
	else if (tmp->type == 'p')
		return (ft_adrpoint(tmp, ap));
	else
		return (ft_char(tmp, ap));
}
Example #2
0
static void		ft_prec(const char *form, va_list *ap, int *i, int *count)
{
	int			precision;
	int			*tab[2];

	precision = 0;
	*i += 2;
	precision = va_arg(*ap, int);
	tab[0] = i;
	tab[1] = &precision;
	if (ft_strchr("eEf", form[*i])
		|| (ft_strchr("lL", form[*i]) && ft_strchr("eEf", form[*i + 1])))
		ft_float(form, ap, tab, count);
	else if (ft_strchr("xXdiuo", form[*i]))
		ft_int(form, ap, tab, count);
	else if (form[*i] == 's')
	{
		*count += ft_putnstr_fd(va_arg(*ap, char*), precision, g_fd);
		*i += 2;
	}