int ft_atoi(char *str)
{
int paire;
int nbout;
paire = 0;
nbout = 0;
while ((*str >= 9 && *str <= 13) || *str == 32)
++str;
while (*str == '+' || *str == '-')
{
if (*str == '-')
{
paire++;
}
str++;
}
while (*str >= 48 && *str <= 57)
{
nbout *= 10;
nbout += *str - 48;
str++;
}
if (!(paire % 2))
return (nbout);
return (-nbout);
}
#include <stdio.h>
int main()
{
char *string = " ---+--+1234ab567";
printf("%d\n", ft_atoi(string));
}
To embed this project on your website, copy the following code and paste it into your website's HTML: