ft_strrchr.c 1.1 KB

12345678910111213141516171819202122232425
  1. /* ************************************************************************** */
  2. /* */
  3. /* ::: :::::::: */
  4. /* ft_strrchr.c :+: :+: :+: */
  5. /* +:+ +:+ +:+ */
  6. /* By: bchanot <bchanot@students.42.fr> +#+ +:+ +#+ */
  7. /* +#+#+#+#+#+ +#+ */
  8. /* Created: 2015/11/25 13:54:03 by bchanot #+# #+# */
  9. /* Updated: 2015/11/27 03:41:08 by bchanot ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #include "libft.h"
  13. char *ft_strrchr(const char *s, int c)
  14. {
  15. int len;
  16. len = ft_strlen(s);
  17. while (s[len] != (char)c && len >= 0)
  18. len--;
  19. if (s[len] == (char)c)
  20. return ((char *)&s[len]);
  21. return (NULL);
  22. }