base struct
This commit is contained in:
28
lib/libft/srcs/mem/ft_memcmp.c
Normal file
28
lib/libft/srcs/mem/ft_memcmp.c
Normal file
@@ -0,0 +1,28 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_memcmp.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/14 11:54:32 by nalebrun #+# #+# */
|
||||
/* Updated: 2024/11/25 16:15:04 by nalebrun ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../libft.h"
|
||||
|
||||
int ft_memcmp(const void *s1, const void *s2, size_t n)
|
||||
{
|
||||
size_t i;
|
||||
const unsigned char *ps1;
|
||||
const unsigned char *ps2;
|
||||
|
||||
ps1 = (const unsigned char *)s1;
|
||||
ps2 = (const unsigned char *)s2;
|
||||
i = -1;
|
||||
while (++i < n)
|
||||
if (ps1[i] != ps2[i])
|
||||
return (ps1[i] - ps2[i]);
|
||||
return (0);
|
||||
}
|
||||
Reference in New Issue
Block a user