aboutsummaryrefslogtreecommitdiff
path: root/c04/ex03
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2019-07-07 15:29:30 +0200
committerCharles <sircharlesaze@gmail.com>2019-07-07 15:29:30 +0200
commita2ef228b981df5ad417a0e8377e1e832002a7644 (patch)
tree32827b5be808bf3123d46856bb753fc190fd3611 /c04/ex03
parent79f8ba0b777f3361002ed2ae0c6c6f8f353ca731 (diff)
downloadpiscine-a2ef228b981df5ad417a0e8377e1e832002a7644.tar.gz
piscine-a2ef228b981df5ad417a0e8377e1e832002a7644.tar.bz2
piscine-a2ef228b981df5ad417a0e8377e1e832002a7644.zip
c04/c05 testing + c06
Diffstat (limited to 'c04/ex03')
-rw-r--r--c04/ex03/ft_atoi.c13
1 files changed, 3 insertions, 10 deletions
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 <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);