ft_atoi.c
/* Function converts ASCII string to integer*/
Function converts ASCII string to integer
Function converts ASCII string to integer
int	ft_atoi(const char *str)
{
	int	i;
	int	nbr;
	int	sign;
	i = 0;
	nbr = 0;
	sign = 1;
	while (str[i] == ' ' || str[i] == '\n' || str[i] == '\r' || str[i] == '\t'
			|| str[i] == '\v' || str[i] == '\f')
		i++;
	if (str[i] == '-' || str[i] == '+')
		if (str[i++] == '-')
			sign = -1;
	while (str[i] >= '0' && str[i] <= '9')
		nbr = (nbr * 10) + (str[i++] - '0');
	return (nbr * sign);
}
int ft_atoi ( const char * str ) { int i ; int nbr ; int sign ; i = 0 ; nbr = 0 ; sign = 1 ; while ( str [ i ] == ' ' || str [ i ] == ' \n ' || str [ i ] == ' \r ' || str [ i ] == ' \t ' || str [ i ] == ' \v ' || str [ i ] == ' \f ' ) i ++ ; if ( str [ i ] == ' ' || str [ i ] == ' ' ) if ( str [ i ++ ] == ' ' ) sign = -1 ; while ( str [ i ] >= ' ' && str [ i ] <= ' ' ) nbr = ( nbr * 10 ) + ( str [ i ++ ] - ' ' ) ; return ( nbr * sign ) ; }
Function converts ASCII string to integer
Function converts ASCII string to integer
/*Skip a char if it is a whitespace */ /*Skip if "+" sign before number. If "-" sign, store the triger to return negative number*/ /*If a char is a digit convert to integer type*/