diff --git a/ft_atoi.c b/ft_atoi.c index 2076acd..60aa4f3 100644 --- a/ft_atoi.c +++ b/ft_atoi.c @@ -6,12 +6,25 @@ /* By: kcolin +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/16 16:06:11 by kcolin #+# #+# */ -/* Updated: 2024/10/16 16:14:38 by kcolin ### ########.fr */ +/* Updated: 2024/10/18 17:58:42 by kcolin ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" +int ft_isspace(char c) +{ + if (c == ' ' + || c == '\f' + || c == '\n' + || c == '\r' + || c == '\t' + || c == '\v') + return (1); + else + return (0); +} + int ft_atoi(const char *nptr) { int result; @@ -19,6 +32,8 @@ int ft_atoi(const char *nptr) result = 0; i = 0; + while (ft_isspace(nptr[i])) + i++; while (ft_isdigit(nptr[i])) { result *= 10;