/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_atoi.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: scebula +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2015/11/26 09:47:14 by scebula #+# #+# */ /* Updated: 2015/12/04 00:21:47 by scebula ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" int ft_atoi(const char *str) { int n; int sign; sign = 1; n = 0; while (ft_isspace(*str)) str++; if (*str == '-') { sign = -1; str++; } else if (*str == '+') { str++; } while (*str && ft_isdigit(*str)) { n = n * 10 + (*str - '0'); str++; } return (n * sign); }