Example #1
0
void	ft_prep_j_int(va_list ap, int *count, int *flags)
{
	char		*str;
	intmax_t	n1;
	uintmax_t	n2;

	str = NULL;
	if (flags[ATTR_SUB_TYPE] == 'd' || flags[ATTR_SUB_TYPE] == 'i')
	{
		n1 = va_arg(ap, intmax_t);
		str = ft_lltoa_base(n1, 10, "0123456789");
		ft_display_int(str, count, flags);
	}
	else
	{
		n2 = va_arg(ap, uintmax_t);
		if (flags[ATTR_SUB_TYPE] == 'x')
			str = ft_ulltoa_base(n2, 16, "0123456789abcdef");
		else if (flags[ATTR_SUB_TYPE] == 'X')
			str = ft_ulltoa_base(n2, 16, "0123456789ABCDEF");
		else if (flags[ATTR_SUB_TYPE] == 'o')
			str = ft_ulltoa_base(n2, 8, "01234567");
		else if (flags[ATTR_SUB_TYPE] == 'u')
			str = ft_ulltoa_base(n2, 10, "0123456789");
		ft_display_int(str, count, flags);
	}
}
Example #2
0
void		ftv_print(t_ftv *ftv)
{
	char	buff[65];

	ft_putstr_fd("Capacity : ", 2);
	ft_putnbr_fd(ftv->capacity, 2);
	ft_putstr_fd("    Size : ", 2);
	ft_putnbr_fd(ftv->size, 2);
	ft_putstr_fd("    Element_size : ", 2);
	ft_putnbr_fd(ftv->element_size, 2);
	ft_putstr_fd("    Data : 0x", 2);
	ft_putstr_fd(ft_ulltoa_base((uint64_t)ftv->data, 16, buff), 2);
	ft_putchar_fd('\n', 2);
}
Example #3
0
void	ft_format_bit(va_list ap, t_format *f)
{
	unsigned long long	n;
	char				*str;
	int					i;

	i = 0;
	n = va_arg(ap, unsigned long long);
	f->nbr = n;
	ft_modif_type_hexa(f, &n);
	str = ft_ulltoa_base(n, 2);
	if (n == 0)
		str = ft_strdup("0");
	f->space = 0;
	ft_print_all(f, str);
}
Example #4
0
static void		convert_arg(t_ullong arg, t_format *f)
{
	char		*tmp;

	if (f->mod_z)
		tmp = ft_uztoa_base((size_t)arg, 10);
	else if (f->mod_ll)
		tmp = ft_ulltoa_base(arg, 10);
	else if (f->mod_j || f->mod_l)
		tmp = ft_ultoa_base((t_ulong)arg, 10);
	else if (f->mod_h)
		tmp = ft_ustoa_base((t_ushort)arg, 10);
	else if (f->mod_hh)
		tmp = ft_uctoa_base((t_uchar)arg, 10);
	else
		tmp = ft_uitoa_base((t_uint)arg, 10);
	f->buf = ft_strdup(tmp);
	free(tmp);
}