More readable ft_atoi function
This commit is contained in:
parent
29151da810
commit
aa916f9db3
|
@ -6,7 +6,7 @@
|
|||
/* By: jtorrez- <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/03/18 20:15:26 by jtorrez- #+# #+# */
|
||||
/* Updated: 2023/03/19 19:25:29 by tischmid ### ########.fr */
|
||||
/* Updated: 2023/03/19 19:26:27 by tischmid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -64,8 +64,12 @@ int ft_atoi(char *str)
|
|||
sign = -1;
|
||||
++i;
|
||||
}
|
||||
i = 0;
|
||||
while (str[i] >= '0' && str[i] <= '9')
|
||||
number = number * 10 + (str[i++] - '0');
|
||||
{
|
||||
number = number * 10 + (str[i] - '0');
|
||||
i = i + 1;
|
||||
}
|
||||
return (sign * number);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue