Add the functions ft_atol and ft_atoll to the file ft_atoi.c.
Add prototypes of these functions to libft.h.
}
return (sign * res);
}
+
+long ft_atol(const char *nptr)
+{
+ long res;
+ int sign;
+
+ res = 0;
+ sign = 1;
+ while (ft_isspace(*nptr))
+ ++nptr;
+ if ((*nptr == '+' || *nptr == '-'))
+ {
+ if (*nptr == '-')
+ sign *= -1;
+ ++nptr;
+ }
+ while (ft_isdigit(*nptr))
+ {
+ res *= 10;
+ res += *nptr - '0';
+ ++nptr;
+ }
+ return (sign * res);
+}
+
+long long ft_atoll(const char *nptr)
+{
+ long long res;
+ int sign;
+
+ res = 0;
+ sign = 1;
+ while (ft_isspace(*nptr))
+ ++nptr;
+ if ((*nptr == '+' || *nptr == '-'))
+ {
+ if (*nptr == '-')
+ sign *= -1;
+ ++nptr;
+ }
+ while (ft_isdigit(*nptr))
+ {
+ res *= 10;
+ res += *nptr - '0';
+ ++nptr;
+ }
+ return (sign * res);
+}
int ft_tolower(int c);
int ft_atoi(const char *nptr);
+long ft_atol(const char *nptr);
+long long ft_atoll(const char *nptr);
char *ft_substr(const char *s, unsigned int start, size_t len);
char *ft_strjoin(const char *s1, const char *s2);