30 lines
1.1 KiB
C
30 lines
1.1 KiB
C
|
/* ************************************************************************** */
|
||
|
/* */
|
||
|
/* ::: :::::::: */
|
||
|
/* ft_strncmp.c :+: :+: :+: */
|
||
|
/* +:+ +:+ +:+ */
|
||
|
/* By: gtertysh <marvin@42.fr> +#+ +:+ +#+ */
|
||
|
/* +#+#+#+#+#+ +#+ */
|
||
|
/* Created: 2016/12/01 14:33:11 by gtertysh #+# #+# */
|
||
|
/* Updated: 2016/12/06 14:23:45 by gtertysh ### ########.fr */
|
||
|
/* */
|
||
|
/* ************************************************************************** */
|
||
|
|
||
|
#include "libft.h"
|
||
|
|
||
|
int ft_strncmp(const char *s1, const char *s2, size_t n)
|
||
|
{
|
||
|
size_t i;
|
||
|
|
||
|
i = 0;
|
||
|
while (i < n && (*s1 || *s2))
|
||
|
{
|
||
|
if (*(unsigned char *)s1 != *(unsigned char *)s2)
|
||
|
return (*(unsigned char *)s1 - *(unsigned char *)s2);
|
||
|
s1++;
|
||
|
s2++;
|
||
|
i++;
|
||
|
}
|
||
|
return (0);
|
||
|
}
|