42_C_PISCINE/Rush/Rush02/ex00/ft_atoapc.c
Camille Chauvet 29ed24d567 init
2023-05-17 16:45:25 +00:00

39 lines
1.2 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_atoapc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/31 20:57:44 by cchauvet #+# #+# */
/* Updated: 2022/07/31 20:58:47 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "rush02.h"
char *ft_atoapc(char *str)
{
int i;
char *tab;
i = -1;
while (*str != ':')
str++;
str++;
while (*str == ' ')
str++;
tab = malloc(sizeof(*tab) * ft_strlen(str));
while (*str)
{
if (tab[i] == '\t')
tab[i] = ' ';
if (tab[i] == ' ' && str[1] == ' ')
while (str[0] == ' ')
str++;
tab[++i] = *str;
str++;
}
return (tab);
}