#include <stdio.h>
int ft_atoi(char *str)
{
int i;
int res;
int sign;
res = 0;
i = 0;
sign = 1;
while (str[i] == 32 || (str[i] >= 9 && str[i] <= 13))
i++;
while (str[i] == '-' || str[i] == '+')
{
if (str[i] == '-')
sign = sign * -1;
i++;
}
while (str[i] >= '0' && str[i] <= '9')
{
res = res * 10 + (str[i] - '0');
i++;
}
return (res * sign);
}
int main(void)
{
char str[] = " ----+--+1234ab567";
printf("%d", ft_atoi(str));
return (0);
}
To embed this project on your website, copy the following code and paste it into your website's HTML: