text: /* ************************************************************************** */
  /*                                                                            */
  /*                                                        :::      ::::::::   */
  /*   ft_atoi.c                                          :+:      :+:    :+:   */
  /*                                                    +:+ +:+         +:+     */
  /*   By: mdesalle <mdesalle@student.s19.be>         +#+  +:+       +#+        */
  /*                                                +#+#+#+#+#+   +#+           */
  /*   Created: 2020/11/12 11:34:55 by mdesalle          #+#    #+#             */
  /*   Updated: 2021/07/13 11:29:42 by mdesalle         ###   ########.fr       */
  /*                                                                            */
  /* ************************************************************************** */
  
  #include "../include/test.h"
  
  long	ft_atoi(const char *nptr)
  {
  	int		sign;
  	long	result;
  
  	sign = 1;
  	result = 0;
  	while (*nptr && ((*nptr >= 9 && *nptr <= 13) || *nptr == ' '))
  		nptr++;
  	if (*nptr == '-')
  		sign = -1;
  	if (*nptr == '-' || *nptr == '+')
  		nptr++;
  	while (*nptr && *nptr >= '0' && *nptr <= '9')
  		result = result * 10 + (*nptr++ - '0');
  	result *= sign;
  	if (result > 0 && sign < 0)
  		return (0);
  	if (result < 0 && sign > 0)
  		return (-1);
  	return (result);
  }
  