0
0
This commit is contained in:
Guy Baconniere
2021-08-16 16:51:24 +02:00
parent 0909750997
commit ef1c6b5e75
16 changed files with 332 additions and 10 deletions

View File

@@ -6,7 +6,7 @@
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/13 12:46:22 by gbaconni #+# #+# */
/* Updated: 2021/08/13 14:58:30 by gbaconni ### ########.fr */
/* Updated: 2021/08/16 13:49:34 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
@@ -17,23 +17,21 @@ int ft_atoi(char *str)
int i;
nb = 0;
s = 0;
s = 1;
i = 0;
while (str[i] != '\0' && (str[i] == ' ' || (str[i] >= '\t' && str[i] <= '\r')))
i++;
while (str[i] != '\0')
{
if (str[i] == ' ' || (str[i] >= '\t' && str[i] <= '\r'))
if (str[i] == '+')
s += 0;
else if (str[i] == '+')
s++;
else if (str[i] == '-')
s--;
s *= -1;
else if (str[i] >= '0' && str[i] <= '9')
nb = nb * 10 + str[i] - '0';
else
break ;
i++;
}
if (s < 0)
nb *= -1;
return (nb);
return (nb * s);
}