Ejemplo n.º 1
0
void				ft_printf_do_pointer(t_printf_parse_env *env,
										va_list args,
										int caps)
{
	char			*s;
	unsigned long	l;

	l = va_arg(args, unsigned long);
	env->ret += ft_putstr_fd("0x", env->fd);
	s = ft_ntoa(l >> 16, 16);
	env->ret += ft_putstr_fd(caps ? ft_strtoupper(s) : s, env->fd);
	s = ft_ntoa(l & 0xffff, 16);
	env->ret += ft_putstr_fd(caps ? ft_strtoupper(s) : s, env->fd);
}
Ejemplo n.º 2
0
static void	padded_print(t_padd *padd, size_t width, int *counter)
{
	char	*s;
	char	*ntoa;

	ntoa = ft_ntoa(padd->num, padd->base);
	ntoa = padd->caps ? ft_strtoupper(ntoa) : ntoa;
	if (!width)
		s = ft_strdup(ntoa);
	else
		s = ft_strndup(ntoa, width);
	if (ft_strlen(s) < width)
	{
		width -= ft_strlen(s);
		while (--width)
			*counter += ft_putchar_fd('0', padd->fd);
	}
	*counter += ft_putstr_fd(s, padd->fd);
	ft_strdel(&s);
}