From f861789c3e5e004395c1b7214757d5a83625d845 Mon Sep 17 00:00:00 2001 From: Dominik Kaiser Date: Wed, 6 Mar 2024 21:02:09 +0100 Subject: Setup and current progress Forgot to commit earlier... --- ft_atoi.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 ft_atoi.c (limited to 'ft_atoi.c') diff --git a/ft_atoi.c b/ft_atoi.c new file mode 100644 index 0000000..6f7bd55 --- /dev/null +++ b/ft_atoi.c @@ -0,0 +1,45 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_atoi.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: dkaiser = '\t' && str[i] <= '\r' || str[i] == ' ') + { + i++; + } + if (str[i] == '-') + { + posneg = -1; + i++; + } + while (str[i] >= '0' && str[i] <= '9') + { + result = 10 * result + str[i] - '0'; + i++; + } + return (result * posneg); +} + +/* #include */ +/* #include */ +/* int main() { */ +/* char str[] = " -42eaeouai"; */ +/* printf("atoi: %d\n", atoi(str)); */ +/* printf("ft_atoi: %d\n", ft_atoi(str)); */ +/* } */ -- cgit v1.2.3