42/d09/ex13/ft_compact.c

36 lines
1.1 KiB
C
Raw Normal View History

2016-11-20 02:20:23 +02:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_compact.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gtertysh <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/04 06:46:08 by gtertysh #+# #+# */
/* Updated: 2016/11/04 07:21:09 by gtertysh ### ########.fr */
/* */
/* ************************************************************************** */
int ft_compact(char **tab, int length)
{
int i;
int j;
i = 0;
while (i < length)
{
if (tab[i] == 0)
{
while (i + 1 < length)
{
tab[i] = tab[i + 1];
i++;
}
length--;
tab[i] = 0;
i = -1;
}
i++;
}
return (length);
}