text: /* ************************************************************************** */
  /*                                                                            */
  /*                                                        :::      ::::::::   */
  /*   ft_atoi.c                                          :+:      :+:    :+:   */
  /*                                                    +:+ +:+         +:+     */
  /*   By: kbui <kbui@student.42.fr>                  +#+  +:+       +#+        */
  /*                                                +#+#+#+#+#+   +#+           */
  /*   Created: 2018/09/13 19:27:10 by kbui              #+#    #+#             */
  /*   Updated: 2018/10/05 22:33:43 by kbui             ###   ########.fr       */
  /*                                                                            */
  /* ************************************************************************** */
  
  #include "libft.h"
  
  int			ft_atoi(const char *str)
  {
  	long long	n;
  	int			isneg;
  
  	isneg = 0;
  	n = 0;
  	while (ft_isspace(*str))
  		str++;
  	if (*str == '+')
  		str++;
  	else if (*str == '-')
  	{
  		isneg = 1;
  		str++;
  	}
  	while (*str != '\0' && ft_isdigit(*str))
  	{
  		n = n * 10 + (*str++ - '0');
  	}
  	if (isneg)
  		return (-n);
  	else
  		return (n);
  }
  