ft_strisdigit.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /* ************************************************************************** */
  2. /* */
  3. /* ::: :::::::: */
  4. /* ft_strisdigit.c :+: :+: :+: */
  5. /* +:+ +:+ +:+ */
  6. /* By: bchanot <bchanot@students.42.fr> +#+ +:+ +#+ */
  7. /* +#+#+#+#+#+ +#+ */
  8. /* Created: 2016/06/16 16:16:37 by bchanot #+# #+# */
  9. /* Updated: 2016/10/16 22:09:34 by bchanot ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #include "libft.h"
  13. int ft_strisdigit(char *str)
  14. {
  15. int i;
  16. int end;
  17. i = -1;
  18. end = 0;
  19. while (str[++i] == ' ')
  20. ;
  21. if (str[i] == '-' || str[i] == '+')
  22. i++;
  23. while (str[i])
  24. {
  25. if ((str[i] >= 48 && str[i] <= 57) && end == 0)
  26. i++;
  27. else if (str[i] == ' ' && end == 0)
  28. end = 1;
  29. else
  30. return (0);
  31. }
  32. return (1);
  33. }