Пример #1
0
int				main(void)
{
	char		*line;
	int			res;
	int			i;
	t_struct	t;
	int			x;

	i = 0;
	x = 0;
	t.liaison = 0;
	t.salle = 0;
	t.lines = malloc(sizeof(char *) * 300);
	while ((res = get_next_line(0, &line) > 0))
	{
		if (i == 0)
		{
			t.nb = ft_atoi(line);
			if (!t.nb)
				return (ft_error());
		}
		t.lines[x] = line;
		ft_putendl(t.lines[x]);
		x++;
		i = ft_parsing(line, &t, i);
	}
	ft_putchar('\n');
	ft_verif(&t);
	//ft_putendl(t.liaison);
	reverseliaison(&t);
	//parlafin(&t);
	makechemin(&t);
	return (0);
}
Пример #2
0
char				*ft_itoa(int nb)
{
	char	*str;
	int		char_nb;

	char_nb = 0;
	if (nb == 0)
		return (ft_strdup("0"));
	if (nb == ENT_MIN)
		return (ft_strdup("-2147483648"));
	char_nb = ft_verif(nb);
	if (!(str = (char *)ft_memalloc(sizeof(char) * (char_nb + 1))))
		return (0);
	if (nb < 0)
	{
		str[0] = '-';
		nb = -nb;
	}
	str[char_nb] = '\0';
	while (nb != 0)
	{
		str[--char_nb] = (nb % 10) + '0';
		nb /= 10;
	}
	return (str);
}
Пример #3
0
long			ft_atoibase(char *str, int base)
{
	int			i;
	long		res;
	int			sign;

	i = 0;
	res = 0;
	sign = ft_verif(str, &i, 1);
	while (ft_isdigit(str[i]) == 1 || (str[i] <= 'f' && str[i] >= 'a') ||
			(str[i] <= 'F' && str[i] >= 'A'))
	{
		if (str[i] == '\0')
			return (res);
		res *= base;
		if (ft_isdigit(str[i]) == 1)
			res += (str[i] - '0') * base;
		else if (str[i] <= 'f' && str[i] >= 'a')
			res += (str[i] - 'a' + 10) * base;
		else if (str[i] <= 'F' && str[i] >= 'A')
			res += (str[i] - 'A' + 10) * base;
		i++;
	}
	return (sign * (res /= base));
}
Пример #4
0
static int		ft_deb(char *s)
{
	int		i;

	i = 0;
	while (ft_verif(s[i]) && s[i] != '\0')
		i++;
	return (i);
}
Пример #5
0
static int		ft_end(char *s)
{
	int		i;

	i = ft_strlen(s);
	if (i > 0)
		i--;
	while (ft_verif(s[i]) && i >= 0)
		i--;
	return (i);
}