ft_strcmp: correct unsigned char cmp

This commit is contained in:
Tanguy MAZE 2018-04-08 15:32:04 +02:00
parent b0e9b728d0
commit 0ecdc73ca9

View File

@ -6,7 +6,7 @@
/* By: tmaze <marvin@42.fr> +#+ +:+ +#+ */ /* By: tmaze <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2018/04/03 15:38:27 by tmaze #+# #+# */ /* Created: 2018/04/03 15:38:27 by tmaze #+# #+# */
/* Updated: 2018/04/05 11:53:33 by tmaze ### ########.fr */ /* Updated: 2018/04/08 15:30:24 by tmaze ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -18,10 +18,10 @@ int ft_strcmp(const char *s1, const char *s2)
int diff; int diff;
i = 1; i = 1;
diff = s1[0] - s2[0]; diff = (unsigned char)s1[0] - (unsigned char)s2[0];
while (diff == 0 && s1[i - 1] && s2[i - 1]) while (diff == 0 && s1[i - 1] && s2[i - 1])
{ {
diff = s1[i] - s2[i]; diff = (unsigned char)s1[i] - (unsigned char)s2[i];
i++; i++;
} }
return (diff); return (diff);