mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
25 lines
1.1 KiB
C
25 lines
1.1 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_memcmp.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: jguelen <marvin@42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2024/10/17 12:34:03 by jguelen #+# #+# */
|
|
/* Updated: 2024/10/17 15:25:56 by jguelen ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include <string.h>
|
|
|
|
int ft_memcmp(const void *s1, const void *s2, size_t n)
|
|
{
|
|
size_t i;
|
|
|
|
i = 0;
|
|
if (n == 0)
|
|
return (0);
|
|
while (i < n - 1 && ((unsigned char *)s1)[i] == ((unsigned char *)s2)[i])
|
|
i++;
|
|
return (((unsigned char *)s1)[i] - ((unsigned char *) s2)[i]);
|
|
}
|