33 lines
1.2 KiB
C
33 lines
1.2 KiB
C
|
/* ************************************************************************** */
|
||
|
/* */
|
||
|
/* ::: :::::::: */
|
||
|
/* ft_atoul_check.c :+: :+: :+: */
|
||
|
/* +:+ +:+ +:+ */
|
||
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||
|
/* +#+#+#+#+#+ +#+ */
|
||
|
/* Created: 2023/03/08 14:43:33 by cchauvet #+# #+# */
|
||
|
/* Updated: 2023/05/02 13:15:12 by cchauvet ### ########.fr */
|
||
|
/* */
|
||
|
/* ************************************************************************** */
|
||
|
|
||
|
#include "./extra.h"
|
||
|
|
||
|
int ft_atoul_check(const char str[])
|
||
|
{
|
||
|
size_t i;
|
||
|
unsigned long num;
|
||
|
|
||
|
num = 0;
|
||
|
i = 0;
|
||
|
while (str[i] != '\0')
|
||
|
{
|
||
|
if (str[i] > '9' || str[i] < '0')
|
||
|
return (0);
|
||
|
if (num > num * 10 + str[i] - '0')
|
||
|
return (0);
|
||
|
num = num * 10 + str[i] - 48;
|
||
|
i++;
|
||
|
}
|
||
|
return (1);
|
||
|
}
|