copy on git
This commit is contained in:
commit
42653de246
205 changed files with 7459 additions and 0 deletions
31
libft/ft_memcmp.c
Executable file
31
libft/ft_memcmp.c
Executable file
|
|
@ -0,0 +1,31 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_memcmp.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: thrieg <thrieg@student.42mulhouse.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/14 17:39:59 by thrieg #+# #+# */
|
||||
/* Updated: 2025/02/16 19:04:06 by thrieg ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
int ft_memcmp(const void *s1, const void *s2, size_t n)
|
||||
{
|
||||
const unsigned char *st1;
|
||||
const unsigned char *st2;
|
||||
|
||||
st1 = (const unsigned char *)s1;
|
||||
st2 = (const unsigned char *)s2;
|
||||
while (n && (*st1 == *st2))
|
||||
{
|
||||
st1++;
|
||||
st2++;
|
||||
n--;
|
||||
}
|
||||
if (n == 0)
|
||||
return (0);
|
||||
return (*st1 - *st2);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue