#include "libft.h"
/*
* ft_atoi() function converts the initial portion of the string pointed to
* by nptr to int.
*/
int ft_atoi(const char *nptr)
{
size_t i;
int mult;
int res;
i = 0;
res = 0;
mult = 1;
while (nptr[i] == 32 || (nptr[i] >= 9 && nptr[i] <= 13))
i++;
if (nptr[i] == '-' || nptr[i] == '+')
{
if (nptr[i] == '-')
mult = -1;
i++;
}
while (nptr[i] >= 48 && nptr[i] <= 57)
res = res * 10 + (nptr[i++] - 48);
return (res * mult);
}