added atoll
This commit is contained in:
3
Makefile
3
Makefile
@ -6,7 +6,7 @@
|
||||
# By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2023/11/01 11:03:22 by adjoly #+# #+# #
|
||||
# Updated: 2024/02/08 16:49:00 by adjoly ### ########.fr #
|
||||
# Updated: 2024/02/15 13:55:20 by adjoly ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
@ -45,6 +45,7 @@ SRCS = is/ft_isalnum.c \
|
||||
print/ft_putstr.c \
|
||||
print/ft_putstr_fd.c \
|
||||
str/ft_atoi.c \
|
||||
str/ft_atoll.c \
|
||||
str/ft_itoa.c \
|
||||
str/ft_split.c \
|
||||
str/ft_strchr.c \
|
||||
|
3
libft.h
3
libft.h
@ -6,7 +6,7 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/01 10:06:03 by adjoly #+# #+# */
|
||||
/* Updated: 2024/02/08 16:50:59 by adjoly ### ########.fr */
|
||||
/* Updated: 2024/02/15 13:55:01 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -26,6 +26,7 @@ typedef struct s_list
|
||||
struct s_list *next;
|
||||
} t_list;
|
||||
|
||||
long long ft_atoll(const char *nptr);
|
||||
int ft_atoi(const char *nptr);
|
||||
void *ft_calloc(size_t nmemb, size_t size);
|
||||
int ft_isalnum(int c);
|
||||
|
35
str/ft_atoll.c
Normal file
35
str/ft_atoll.c
Normal file
@ -0,0 +1,35 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_atoll.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/10/31 09:00:27 by adjoly #+# #+# */
|
||||
/* Updated: 2024/02/15 13:49:15 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
long long ft_atoll(const char *nptr)
|
||||
{
|
||||
char sign;
|
||||
long long nbr;
|
||||
|
||||
sign = 1;
|
||||
nbr = 0;
|
||||
while ((*nptr >= 7 && *nptr <= 13) || *nptr == 32)
|
||||
nptr++;
|
||||
if (*nptr == '-')
|
||||
{
|
||||
sign *= -1;
|
||||
nptr++;
|
||||
}
|
||||
else if (*nptr == '+')
|
||||
nptr++;
|
||||
while (*nptr >= '0' && *nptr <= '9')
|
||||
{
|
||||
nbr = nbr * 10 + (*nptr - '0');
|
||||
nptr++;
|
||||
}
|
||||
return (nbr * sign);
|
||||
}
|
Reference in New Issue
Block a user