base c lib without external lib

This commit is contained in:
David Gailleton
2025-11-05 19:25:22 +01:00
parent e06b98052a
commit 697e044d7e
19 changed files with 445 additions and 13 deletions

22
ft_memcmp.c Normal file
View File

@@ -0,0 +1,22 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/05 18:00:38 by dgaillet #+# #+# */
/* Updated: 2025/11/05 18:05:28 by dgaillet ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_memcmp(const void *s1, const void *s2, size_t n)
{
if (n <= 0)
return (0);
if (*((unsigned char *) s1) != *((unsigned char *) s2))
return (*((unsigned char *) s1) - *((unsigned char *) s2));
return (ft_memcmp(s1 + 1, s2 + 1, n - 1));
}