/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strncmp.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/08/07 10:49:12 by jhalford #+# #+# */ /* Updated: 2016/08/15 22:25:07 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" int ft_strncmp(const char *s1, const char *s2, size_t n) { int cmp; size_t i; i = 0; while (1) { cmp = (s1[i] - s2[i]); if (i >= n - 1) return (cmp); if (s1[i] == '\0' && s2[i] == '\0') return (cmp); if (s1[i] == s2[i]) i++; else return (cmp); } }