Ejemplo n.º 1
0
static void		split(char **ret, const char *s, char c)
{
	size_t	j;
	size_t	size;
	char	*word;

	j = 0;
	while (*s)
	{
		size = size_word(s, c);
		if (size)
		{
			word = ft_strsub(s, 0, size);
			ret[j] = word;
			j++;
		}
		s += size;
		while (*s == c)
			++s;
	}
	ret[j] = NULL;
}
Ejemplo n.º 2
0
static void		put_int_in_tab(int nb_w, char c, int *tab, char *s)
{
	int	i;
	int	j;
	int	size;

	size = 0;
	i = 0;
	j = 0;
	while (s[i] != '\0' && j < nb_w)
	{
		if ((s[i] == c && s[i + 1] != c && s[i + 1] != '\0') ||
				(s[0] != c && i == 0))
		{
			if (s[i] == c)
				i++;
			size = size_word(&s[i], c);
			tab[j] = ft_atoi(ft_strsub(s, i, size));
			j++;
		}
		i++;
	}
}