ft_strcmp.c 1.1 KB

1234567891011121314151617181920212223
  1. /* ************************************************************************** */
  2. /* */
  3. /* ::: :::::::: */
  4. /* ft_strcmp.c :+: :+: :+: */
  5. /* +:+ +:+ +:+ */
  6. /* By: bchanot <bchanot@students.42.fr> +#+ +:+ +#+ */
  7. /* +#+#+#+#+#+ +#+ */
  8. /* Created: 2015/11/23 16:52:55 by bchanot #+# #+# */
  9. /* Updated: 2015/11/29 16:42:38 by bchanot ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #include "libft.h"
  13. int ft_strcmp(const char *s1, const char *s2)
  14. {
  15. int cpt;
  16. cpt = 0;
  17. while (s1[cpt] == s2[cpt] && s1[cpt] && s2[cpt])
  18. cpt++;
  19. return ((unsigned char)s1[cpt] - (unsigned char)s2[cpt]);
  20. }