ft_strichr.c 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. /* ************************************************************************** */
  2. /* */
  3. /* ::: :::::::: */
  4. /* ft_strichr.c :+: :+: :+: */
  5. /* +:+ +:+ +:+ */
  6. /* By: bchanot <marvin@42.fr> +#+ +:+ +#+ */
  7. /* +#+#+#+#+#+ +#+ */
  8. /* Created: 2015/12/03 11:37:13 by bchanot #+# #+# */
  9. /* Updated: 2018/10/29 11:58:15 by bchanot ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #include "libft.h"
  13. size_t ft_strichr(const char *const s, int c)
  14. {
  15. size_t i;
  16. i = 0;
  17. if (!s || !c)
  18. return (false);
  19. while (s[i])
  20. {
  21. if (s[i] == (char)c)
  22. return (i);
  23. i++;
  24. }
  25. if (s[i] == (char)c)
  26. return (i);
  27. return (-1);
  28. }