Files
42_INT_01_libft/srcs/ft_atoi.c
2026-05-06 20:02:44 +02:00

27 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_atoi.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/11/25 13:54:29 by hulamy #+# #+# */
/* Updated: 2019/11/25 13:54:35 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_atoi(const char *str)
{
long long result = ft_atoll(str);
// clamp to int range
if (result > INT_MAX)
return INT_MAX;
if (result < INT_MIN)
return INT_MIN;
return (int)result;
}