Adding the libft
This commit is contained in:
parent
1b98b537b7
commit
c947e43e51
62 changed files with 2098 additions and 19 deletions
31
libft/memory/ft_memcmp.c
Normal file
31
libft/memory/ft_memcmp.c
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_memcmp.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:49:04 by rparodi #+# #+# */
|
||||
/* Updated: 2023/11/07 18:46:15 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
int ft_memcmp(const void *s1, const void *s2, size_t n)
|
||||
{
|
||||
size_t i;
|
||||
unsigned char *str1;
|
||||
unsigned char *str2;
|
||||
|
||||
i = 0;
|
||||
str1 = (unsigned char *)s1;
|
||||
str2 = (unsigned char *)s2;
|
||||
while (i < n)
|
||||
{
|
||||
if (str1[i] != str2[i])
|
||||
return (str1[i] - str2[i]);
|
||||
i++;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue