ft_cptchar.c 1.1 KB

1234567891011121314151617181920212223242526272829
  1. /* ************************************************************************** */
  2. /* */
  3. /* ::: :::::::: */
  4. /* ft_cptchar.c :+: :+: :+: */
  5. /* +:+ +:+ +:+ */
  6. /* By: bchanot <bchanot@students.42.fr> +#+ +:+ +#+ */
  7. /* +#+#+#+#+#+ +#+ */
  8. /* Created: 2015/12/23 15:16:22 by bchanot #+# #+# */
  9. /* Updated: 2018/10/13 20:10:40 by bchanot ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #include "libft.h"
  13. size_t ft_cptchar(const char *src, char c)
  14. {
  15. size_t i;
  16. i = 0;
  17. if (!src || !c)
  18. return (0);
  19. while (*src)
  20. {
  21. if (*src == c)
  22. i++;
  23. src++;
  24. }
  25. return (i);
  26. }