ft_strcmp.c 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. /* ************************************************************************** */
  2. /* */
  3. /* ::: :::::::: */
  4. /* ft_strcmp.c :+: :+: :+: */
  5. /* +:+ +:+ +:+ */
  6. /* By: mazimi <mazimi@student.42.fr> +#+ +:+ +#+ */
  7. /* +#+#+#+#+#+ +#+ */
  8. /* Created: 2014/11/07 17:14:39 by mazimi #+# #+# */
  9. /* Updated: 2014/12/02 16:00:19 by mazimi ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #include "../libft.h"
  13. int ft_strcmp(const char *s1, const char *s2)
  14. {
  15. unsigned char s11;
  16. unsigned char s22;
  17. if (s1 == NULL && s2 == NULL)
  18. return (0);
  19. else if (s1 == NULL || s2 == NULL)
  20. return (-122);
  21. s11 = *s1;
  22. s22 = *s2;
  23. if (!s11 && !s22)
  24. return (0);
  25. else if (s11 != s22)
  26. return (s11 - s22);
  27. return (ft_strcmp(++s1, ++s2));
  28. }