init
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strncmp.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rzy <ry@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2026/08/23 23:18:37 by rzy #+# #+# */
|
||||
/* Updated: 2026/08/23 23:20:35 by rzy ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
#include "libft.h"
|
||||
|
||||
int ft_strncmp(const char *s1, const char *s2, size_t n)
|
||||
{
|
||||
unsigned char *s1_ptr;
|
||||
unsigned char *s2_ptr;
|
||||
size_t i;
|
||||
|
||||
s1_ptr = (unsigned char *)s1;
|
||||
s2_ptr = (unsigned char *)s2;
|
||||
i = 0;
|
||||
while (i < n)
|
||||
{
|
||||
if (!s1_ptr[i] && !s2_ptr[i])
|
||||
return (0);
|
||||
if (s1_ptr[i] != s2_ptr[i])
|
||||
return (s1_ptr[i] - s2_ptr[i]);
|
||||
++i;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
Reference in New Issue
Block a user