text: /* ************************************************************************** */
  /*                                                                            */
  /*                                                        :::      ::::::::   */
  /*   ft_atoi.c                                          :+:      :+:    :+:   */
  /*                                                    +:+ +:+         +:+     */
  /*   By: asansyzb <marvin@42.fr>                    +#+  +:+       +#+        */
  /*                                                +#+#+#+#+#+   +#+           */
  /*   Created: 2018/10/23 15:20:25 by asansyzb          #+#    #+#             */
  /*   Updated: 2019/04/07 22:20:07 by asansyzb         ###   ########.fr       */
  /*                                                                            */
  /* ************************************************************************** */
  
  #include "libft.h"
  
  int	ft_atoi(const char *nptr)
  {
  	size_t	i;
  	int		sign;
  	int		res;
  
  	i = 0;
  	sign = 1;
  	res = 0;
  	while (nptr[i] && ((nptr[i] > 6 && nptr[i] < 14) || nptr[i] == 32))
  		i++;
  	if (nptr[i] == '+' || nptr[i] == '-')
  		if (nptr[i++] == '-')
  			sign = -1;
  	while (nptr[i] >= '0' && nptr[i] <= '9')
  		res = (res * 10) + (nptr[i++] - '0');
  	return (res * sign);
  }
  