26 lines
1.1 KiB
C
26 lines
1.1 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_strncmp.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2016/08/07 10:49:12 by jhalford #+# #+# */
|
|
/* Updated: 2016/11/03 16:11:00 by jhalford ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "libft.h"
|
|
|
|
int ft_strncmp(const char *s1, const char *s2, size_t n)
|
|
{
|
|
int i;
|
|
|
|
i = 0;
|
|
while (*(s1 + i) && *(s1 + i) == *(s2 + i) && i < (int)n)
|
|
i++;
|
|
if (i < (int)n)
|
|
return (*((unsigned char*)s1 + i) - *((unsigned char*)s2 + i));
|
|
else
|
|
return (0);
|
|
}
|