ft_strnequ.c 1.2 KB

12345678910111213141516171819202122232425262728
  1. /* ************************************************************************** */
  2. /* */
  3. /* ::: :::::::: */
  4. /* ft_strnequ.c :+: :+: :+: */
  5. /* +:+ +:+ +:+ */
  6. /* By: mazimi <mazimi@student.42.fr> +#+ +:+ +#+ */
  7. /* +#+#+#+#+#+ +#+ */
  8. /* Created: 2014/11/06 18:27:18 by mazimi #+# #+# */
  9. /* Updated: 2014/12/08 15:50:50 by mazimi ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #include "../libft.h"
  13. int ft_strnequ(char const *s1, char const *s2, size_t n)
  14. {
  15. if (s1 == NULL || s2 == NULL)
  16. return (0);
  17. if (n == 0)
  18. return (1);
  19. if (*s1 == '\0' && *s2 == '\0')
  20. return (1);
  21. if (n == 1 && *s1 == *s2)
  22. return (1);
  23. if (*s1 == *s2 && n)
  24. return (ft_strnequ(s1 + 1, s2 + 1, n - 1));
  25. return (0);
  26. }