Added memorybook to parsing and cleaned most of the files
This commit is contained in:
33
libs/libft/srcs/ft_atoi.c
Normal file
33
libs/libft/srcs/ft_atoi.c
Normal file
@@ -0,0 +1,33 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_atoi.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/11/25 13:54:29 by hulamy #+# #+# */
|
||||
/* Updated: 2022/05/04 14:09:01 by pblagoje ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
int ft_atoi(const char *str)
|
||||
{
|
||||
long nbr;
|
||||
int i;
|
||||
int negatif;
|
||||
|
||||
i = 0;
|
||||
negatif = 1;
|
||||
nbr = 0;
|
||||
while ((str[i] == ' ') || (str[i] > 8 && str[i] < 14))
|
||||
i++;
|
||||
if (str[i] == '-')
|
||||
negatif = -1;
|
||||
if (str[i] == '+' || str[i] == '-')
|
||||
i++;
|
||||
while (str[i] >= '0' && str[i] <= '9')
|
||||
nbr = nbr * 10 + (str[i++] - '0');
|
||||
return (nbr * negatif);
|
||||
}
|
||||
Reference in New Issue
Block a user