35 lines
1.2 KiB
C
35 lines
1.2 KiB
C
|
/* ************************************************************************** */
|
||
|
/* */
|
||
|
/* :::::::: */
|
||
|
/* ft_strncmp.c |o_o || | */
|
||
|
/* +:+ */
|
||
|
/* By: djonker <marvin@codam.nl> +#+ */
|
||
|
/* +#+ */
|
||
|
/* Created: 2020/11/01 19:09:01 by djonker #+# #+# */
|
||
|
/* Updated: 2023/03/03 14:28:11 by houtworm \___)=(___/ */
|
||
|
/* */
|
||
|
/* ************************************************************************** */
|
||
|
|
||
|
#include "../libft.h"
|
||
|
|
||
|
int ft_strncmp(char *s1, char *s2, unsigned int n)
|
||
|
{
|
||
|
if (s1 == NULL && s2 == NULL)
|
||
|
return (0);
|
||
|
if (s1 == NULL || s2 == NULL)
|
||
|
return (1);
|
||
|
if (n == 0)
|
||
|
return (0);
|
||
|
while (n)
|
||
|
{
|
||
|
if (*s1 != *s2)
|
||
|
return (*(unsigned char *)s1 - *(unsigned char *)s2);
|
||
|
if (*s1 == '\0')
|
||
|
break ;
|
||
|
s1++;
|
||
|
s2++;
|
||
|
n--;
|
||
|
}
|
||
|
return (0);
|
||
|
}
|