36 lines
1.2 KiB
C
36 lines
1.2 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_strncmp.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: mdenys <mdenys@student.42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2020/10/29 12:22:15 by mdenys #+# #+# */
|
|
/* Updated: 2020/11/05 17:52:29 by mdenys ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "libft.h"
|
|
|
|
int ft_strncmp(const char *s1, const char *s2, size_t a)
|
|
{
|
|
unsigned int i;
|
|
unsigned char *d;
|
|
unsigned char *s;
|
|
|
|
d = (unsigned char *)s1;
|
|
s = (unsigned char *)s2;
|
|
i = 0;
|
|
while (d[i] && s[i] && i < a)
|
|
{
|
|
if (d[i] != s[i])
|
|
return (d[i] - s[i]);
|
|
i++;
|
|
}
|
|
if (i != a)
|
|
{
|
|
return (d[i] - s[i]);
|
|
}
|
|
return (0);
|
|
}
|