mirror of
https://codeberg.org/ACME-Corporation/cub3d.git
synced 2025-12-06 09:58:09 +01:00
Added libft and mlx
This commit is contained in:
parent
8448ae3a23
commit
82d06d234a
122 changed files with 10400 additions and 0 deletions
37
libft/src/str/ft_atoi.c
Normal file
37
libft/src/str/ft_atoi.c
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_atoi.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tchampio <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/15 17:02:23 by tchampio #+# #+# */
|
||||
/* Updated: 2024/10/15 17:23:50 by tchampio ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../includes/libft.h"
|
||||
|
||||
int ft_atoi(const char *s)
|
||||
{
|
||||
int isnegative;
|
||||
int res;
|
||||
|
||||
res = 0;
|
||||
isnegative = 1;
|
||||
while (*s == ' ' || *s == '\f' || *s == '\r' || *s == '\v' || *s == '\t'
|
||||
|| *s == '\n')
|
||||
s++;
|
||||
if (*s == '-' || *s == '+')
|
||||
{
|
||||
if (*s == '-')
|
||||
isnegative = -1;
|
||||
s++;
|
||||
}
|
||||
while (*s >= '0' && *s <= '9')
|
||||
{
|
||||
res = (res * 10) + (*s - '0');
|
||||
s++;
|
||||
}
|
||||
return (res * isnegative);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue