tgrekov-libft
HIVE libft Oct 2023
Loading...
Searching...
No Matches
ft_memcmp.c
Go to the documentation of this file.
1
/* ************************************************************************** */
2
/* */
3
/* ::: :::::::: */
4
/* ft_memcmp.c :+: :+: :+: */
5
/* +:+ +:+ +:+ */
6
/* By: tgrekov <tgrekov@student.hive.fi> +#+ +:+ +#+ */
7
/* +#+#+#+#+#+ +#+ */
8
/* Created: 2023/10/24 17:54:51 by tgrekov #+# #+# */
9
/* Updated: 2023/11/04 22:46:48 by tgrekov ### ########.fr */
10
/* */
11
/* ************************************************************************** */
12
20
#include "
libft.h
"
21
34
int
ft_memcmp
(
const
void
*s1,
const
void
*s2,
size_t
n)
35
{
36
size_t
i;
37
int
diff;
38
39
i = 0;
40
while
(i < n)
41
{
42
diff = ((
unsigned
char
*) s1)[i] - ((
unsigned
char
*) s2)[i];
43
if
(diff)
44
return
(diff);
45
i++;
46
}
47
return
(0);
48
}
ft_memcmp
int ft_memcmp(const void *s1, const void *s2, size_t n)
Compares n bytes of byte string s1 against byte string s2.
Definition
ft_memcmp.c:34
libft.h
ft_memcmp.c