From a2ef228b981df5ad417a0e8377e1e832002a7644 Mon Sep 17 00:00:00 2001 From: Charles Date: Sun, 7 Jul 2019 15:29:30 +0200 Subject: c04/c05 testing + c06 --- c04/ex03/ft_atoi.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'c04/ex03') diff --git a/c04/ex03/ft_atoi.c b/c04/ex03/ft_atoi.c index 10f6b07..a26308e 100644 --- a/c04/ex03/ft_atoi.c +++ b/c04/ex03/ft_atoi.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/07/06 07:31:38 by cacharle #+# #+# */ -/* Updated: 2019/07/06 10:23:20 by cacharle ### ########.fr */ +/* Updated: 2019/07/06 15:48:43 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -31,29 +31,22 @@ int ft_atoi(char *str) int j; while (*str == ' ' || *str == '\t' || *str == '\n' - || *str == '\v' || *str == '\f' || *str == '\r') + || *str == '\v' || *str == '\f' || *str == '\r') str++; is_negative = 0; - /*printf("> %s\n", str);*/ while (*str == '-' || *str == '+') { if (*str == '-') is_negative = !is_negative; str++; } - /*printf("> %s\n", str);*/ nb = 0; i = 0; while (str[i] >= '0' && str[i] <= '9') i++; j = 0; while (str[j] >= '0' && str[j] <= '9') - { - /*printf("%d i, %d nb\n", i, nb);*/ - i--; - nb += pow10(i) * (str[j] - '0'); - j++; - } + nb += pow10(--i) * (str[j++] - '0'); if (is_negative) nb = -nb; return (nb); -- cgit