text: /* ************************************************************************** */
  /*                                                                            */
  /*                                                        :::      ::::::::   */
  /*   ft_atoi.c                                          :+:      :+:    :+:   */
  /*                                                    +:+ +:+         +:+     */
  /*   By: vokrut <marvin@42.fr>                      +#+  +:+       +#+        */
  /*                                                +#+#+#+#+#+   +#+           */
  /*   Created: 2019/02/14 10:36:41 by vokrut            #+#    #+#             */
  /*   Updated: 2019/02/23 21:05:27 by vokrut           ###   ########.fr       */
  /*                                                                            */
  /* ************************************************************************** */
  
  #include "libft.h"
  
  /* Function converts ASCII string to integer*/
  
  int	ft_atoi(const char *str)
  {
  	int	i;
  	int	nbr;
  	int	sign;
  
  	i = 0;
  	nbr = 0;
  	sign = 1;
  	/*Skip a char if it is a whitespace */
  	while (str[i] == ' ' || str[i] == '\n' || str[i] == '\r' || str[i] == '\t'
  			|| str[i] == '\v' || str[i] == '\f')
  		i++;
  	/*Skip if "+" sign before number. If "-" sign, store the triger to return negative number*/
  	if (str[i] == '-' || str[i] == '+')
  		if (str[i++] == '-')
  			sign = -1;
  	/*If a char is a digit convert to integer type*/
  	while (str[i] >= '0' && str[i] <= '9')
  		nbr = (nbr * 10) + (str[i++] - '0');
  	return (nbr * sign);
  }
  