ft_cptchar_glued.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /* ************************************************************************** */
  2. /* */
  3. /* ::: :::::::: */
  4. /* ft_cptchar_glued.c :+: :+: :+: */
  5. /* +:+ +:+ +:+ */
  6. /* By: bchanot <bchanot@student.42.fr> +#+ +:+ +#+ */
  7. /* +#+#+#+#+#+ +#+ */
  8. /* Created: 2017/04/28 00:56:56 by bchanot #+# #+# */
  9. /* Updated: 2018/10/29 12:15:35 by bchanot ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #include "libft.h"
  13. size_t ft_cptchar_glued(const char *src, char c)
  14. {
  15. size_t i;
  16. size_t j;
  17. j = 0;
  18. if (!src || !ft_cptchar(src, c))
  19. return (0);
  20. while (*src)
  21. {
  22. if (*src == c)
  23. {
  24. i = 0;
  25. while (*src && *src == c)
  26. {
  27. src++;
  28. i++;
  29. }
  30. if (i > j)
  31. j = i;
  32. }
  33. else
  34. src++;
  35. }
  36. return (j);
  37. }