/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_atoi.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: vvobis +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/04/10 10:49:04 by vvobis #+# #+# */ /* Updated: 2024/08/17 21:39:08 by victor ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" int is_space(char const c) { if ((c >= 9 && c <= 13) || c == ' ') return (1); return (0); } int ft_atoi(char const *s) { int nb; char const *tmp; nb = 0; while (is_space(*s)) s++; tmp = s; if (*tmp == '+' || *tmp == '-') tmp++; while (*tmp >= '0' && *tmp <= '9') { nb *= 10; nb += (*tmp - '0'); tmp++; } if (*s == '-') nb = -nb; return (nb); }