ajout des fonctions atol free_tab et isnumber

This commit is contained in:
hugogogo
2021-09-27 16:51:48 +02:00
parent c335eb1f6a
commit d622367cfd
11 changed files with 221 additions and 23 deletions

View File

@@ -14,26 +14,20 @@
int ft_atoi(const char *str)
{
long long nbr;
long nbr;
int i;
int n;
int negatif;
i = 0;
n = 1;
negatif = 1;
nbr = 0;
while ((str[i] == ' ') || (str[i] > 8 && str[i] < 14))
i++;
if (str[i] == '-')
n = -1;
negatif = -1;
if (str[i] == '+' || str[i] == '-')
i++;
while (str[i] >= '0' && str[i] <= '9')
{
if ((nbr >= 922337203685477580
&& ((str[i] > 8 && n < 0) || (str[i] > 7 && n > 0))))
return ((n > 0) ? -1 : 0);
else
nbr = nbr * 10 + (str[i++] - '0');
}
return (nbr * n);
nbr = nbr * 10 + (str[i++] - '0');
return (nbr * negatif);
}