remove recurssive function + commented main

This commit is contained in:
David Gailleton
2025-11-11 13:49:56 +01:00
parent c4e4c7c141
commit c722e2b87d
18 changed files with 93 additions and 140 deletions

View File

@@ -6,7 +6,7 @@
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/05 18:00:38 by dgaillet #+# #+# */
/* Updated: 2025/11/06 11:17:32 by dgaillet ### ########lyon.fr */
/* Updated: 2025/11/11 11:59:58 by dgaillet ### ########lyon.fr */
/* */
/* ************************************************************************** */
@@ -14,11 +14,16 @@
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 (1);
if (*(unsigned char *) s1 < *(unsigned char *) s2)
return (-1);
return (ft_memcmp(s1 + 1, s2 + 1, n - 1));
size_t i;
i = 0;
while (i < n)
{
if (((unsigned char *) s1)[i] > ((unsigned char *) s2)[i])
return (1);
if (((unsigned char *) s1)[i] < ((unsigned char *) s2)[i])
return (-1);
i++;
}
return (0);
}