More readable ft_atoi function

This commit is contained in:
Timo Schmidt 2023-03-19 19:26:40 +01:00
parent 29151da810
commit aa916f9db3
1 changed files with 6 additions and 2 deletions

View File

@ -6,7 +6,7 @@
/* By: jtorrez- <marvin@42.fr> +#+ +:+ +#+ */ /* By: jtorrez- <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/18 20:15:26 by jtorrez- #+# #+# */ /* 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; sign = -1;
++i; ++i;
} }
i = 0;
while (str[i] >= '0' && str[i] <= '9') 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); return (sign * number);
} }