This commit is contained in:
rzy
2026-08-31 02:16:33 +02:00
commit 94cd5aac51
25 changed files with 705 additions and 0 deletions
+32
View File
@@ -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);
}