42-archive/libft/srcs/str/ft_strcmp.c
2017-03-31 18:40:30 +02:00

25 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/08/07 10:49:02 by jhalford #+# #+# */
/* Updated: 2017/03/14 18:09:26 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_strcmp(const char *s1, const char *s2)
{
int i;
i = 0;
if (!s1 || !s2)
return (1);
while (*(s1 + i) && *(s1 + i) == *(s2 + i))
i++;
return (*((unsigned char*)s1 + i) - *((unsigned char*)s2 + i));
}