Esempio n. 1
0
void			ft_dec(t_elem *tmpa, char **str, int *cpt_null)
{
	(void)cpt_null;
	*str = mod_dec(tmpa);
	if (ft_atoi(*str) == 0 && SPREC.pt == 1)
	{
		ft_strdel(str);
		*str = ft_strdup("");
		ft_positive(tmpa, str);
	}
	else if ((*str)[0] == '-')
		ft_negative(tmpa, str);
	else
		ft_positive(tmpa, str);
}
Esempio n. 2
0
char			*ft_itoa(int n)
{
	char	*a;
	int		i;

	if (n == -2147483648)
		return ((a = "-2147483648"));
	i = ft_nbrlen(n);
	a = (char *)malloc(sizeof(char) * i + 1);
	if (a == NULL)
		return (NULL);
	if (n < 0 && ++i)
		a[0] = '-';
	a[i] = '\0';
	while (n / 10 != 0)
	{
		a[--i] = ft_positive(ft_unite(n)) + '0';
		n = n / 10;
	}
	a[--i] = ft_positive(ft_unite(n)) + '0';
	return (a);
}