ft_atoi.c

This commit is contained in:
Timo Schmidt 2023-03-28 03:26:25 +02:00
parent fb8dc3538b
commit 6546e29ae5
1 changed files with 47 additions and 0 deletions

47
ex03/ft_atoi.c Normal file
View File

@ -0,0 +1,47 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_atoi.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/27 19:51:48 by tischmid #+# #+# */
/* Updated: 2023/03/28 03:26:16 by tischmid ### ########.fr */
/* */
/* ************************************************************************** */
int ft_isspace(char c)
{
return (c == ' '
|| c == '\t'
|| c == '\n'
|| c == '\r'
|| c == '\f'
|| c == '\v');
}
int ft_atoi(char *str)
{
while (ft_isspace(*str))
++str;
return (0);
}
/* ////
#include <stdio.h>
int main(void)
{
printf(": %d\n", ft_atoi(""));
printf("0: %d\n", ft_atoi("0"));
printf("1: %d\n", ft_atoi("1"));
printf("14: %d\n", ft_atoi("14"));
printf("120: %d\n", ft_atoi("120"));
printf("-0: %d\n", ft_atoi("-0"));
printf("-1: %d\n", ft_atoi("-1"));
printf("-14: %d\n", ft_atoi("-14"));
printf("-120: %d\n", ft_atoi("-120"));
printf("2147483647: %d\n", ft_atoi("2147483647"));
printf("-2147483648: %d\n", ft_atoi("-2147483648"));
}
*/ ////