42-archive/42-piscine-c/d10/ex00/srcs/ft_strcmp.c
2016-08-25 20:50:28 +02:00

30 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/08/02 14:27:37 by jhalford #+# #+# */
/* Updated: 2016/08/09 10:47:38 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
int ft_strcmp(char *s1, char *s2)
{
int cmp;
int i;
i = 0;
cmp = 0;
while (1 == 1)
{
cmp += (s1[i] - s2[i]);
if (s1[i] == '\0' && s2[i] == '\0')
return (cmp);
if (s1[i] == s2[i])
i++;
else
return (cmp);
}
}