ft_search_pos_char.c 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. /* ************************************************************************** */
  2. /* */
  3. /* ::: :::::::: */
  4. /* ft_search_pos_char.c :+: :+: :+: */
  5. /* +:+ +:+ +:+ */
  6. /* By: mazimi <marvin@42.fr> +#+ +:+ +#+ */
  7. /* +#+#+#+#+#+ +#+ */
  8. /* Created: 2016/10/12 18:07:23 by mazimi #+# #+# */
  9. /* Updated: 2016/10/12 18:07:25 by mazimi ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #include "../libft.h"
  13. /*
  14. ** Return string's position of first occurence of searched char
  15. ** If char not found, return '-1'
  16. */
  17. int ft_search_pos_char(const char *s1, char c)
  18. {
  19. int i;
  20. i = -1;
  21. while (s1[++i] != '\0')
  22. if (s1[i] == c)
  23. return (i);
  24. if (s1[i] == c)
  25. return (i);
  26. return (-1);
  27. }