github to gitea
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_atoll.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: lfirmin <[email protected]> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/11/03 17:25:06 by lfirmin #+# #+# */
|
||||
/* Updated: 2024/11/03 17:25:33 by lfirmin ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
long long ft_atoll(const char *str)
|
||||
{
|
||||
long long result;
|
||||
int sign;
|
||||
|
||||
result = 0;
|
||||
sign = 1;
|
||||
while (*str == ' ' || (*str >= 9 && *str <= 13))
|
||||
str++;
|
||||
if (*str == '-' || *str == '+')
|
||||
{
|
||||
if (*str == '-')
|
||||
sign = -1;
|
||||
str++;
|
||||
}
|
||||
while (*str >= '0' && *str <= '9')
|
||||
{
|
||||
if (result > INT_MAX || result < INT_MIN)
|
||||
return (2147483648);
|
||||
result = result * 10 + (*str - '0');
|
||||
str++;
|
||||
}
|
||||
return (result * sign);
|
||||
}
|
||||
Reference in New Issue
Block a user