piscine/c02/ex03/ft_str_is_numeric.c
Willem Haffmans 607ce08c18 all
2024-09-10 00:18:01 +02:00

42 lines
1.3 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_str_is_numeric.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/06 14:38:19 by whaffman #+# #+# */
/* Updated: 2024/06/06 15:14:48 by whaffman ### ########.fr */
/* */
/* ************************************************************************** */
int ft_str_is_numeric(char *str)
{
int is_numeric;
is_numeric = 1;
while (*str != '\0')
{
if (*str < '0' || *str > '9')
{
is_numeric = 0;
}
str++;
}
return (is_numeric);
}
/*
#include <stdio.h>
int main(void)
{
char *s1 = "";
char *s2 = "123";
char *s3 = "123f";
printf("%d, %d, %d", \
ft_str_is_numeric(s1),
ft_str_is_numeric(s2),
ft_str_is_numeric(s3));
return (0);
}
*/