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

22
srcs/ft_atol.c Normal file
View File

@@ -0,0 +1,22 @@
#include "libft.h"
long ft_atol(const char *str)
{
long long nbr;
int i;
int negatif;
i = 0;
negatif = 1;
nbr = 0;
while ((str[i] == ' ') || (str[i] > 8 && str[i] < 14))
i++;
if (str[i] == '-')
negatif = -1;
if (str[i] == '+' || str[i] == '-')
i++;
while (str[i] >= '0' && str[i] <= '9')
nbr = nbr * 10 + (str[i++] - '0');
return (nbr * negatif);
}