39 lines
1.2 KiB
C
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);
|
|
}
|