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

33 lines
1.2 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_atonbr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nlauvray <nlauvray@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/31 08:46:00 by nlauvray #+# #+# */
/* Updated: 2022/07/31 08:46:12 by nlauvray ### ########.fr */
/* */
/* ************************************************************************** */
#include "rush02.h"
char *ft_atonbr(char *str)
{
char *str_out;
int i;
i = 0;
while (str[i] >= '0' && str[i] <= '9')
i++;
str_out = malloc(sizeof(*str) * (i + 1));
i = 0;
while (str[i] >= '0' && str[i] <= '9')
{
str_out[i] = str[i];
i++;
}
str_out[i] = '\0';
return (str_out);
}