42_C_PISCINE/Rush/Rush02/ex00/ft_atonbr.c

33 lines
1.2 KiB
C
Raw Normal View History

2023-05-17 12:45:25 -04:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* 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);
}