Libft
42 Libft library documentation
Loading...
Searching...
No Matches
ft_memcmp.c
Go to the documentation of this file.
1
/* ************************************************************************** */
2
/* */
3
/* ::: :::::::: */
4
/* ft_memcmp.c :+: :+: :+: */
5
/* +:+ +:+ +:+ */
6
/* By: raphalme <raphalme@student.42.fr> +#+ +:+ +#+ */
7
/* +#+#+#+#+#+ +#+ */
8
/* Created: 2025/12/29 18:52:00 by raphalme #+# #+# */
9
/* Updated: 2026/04/14 10:45:22 by raphalme ### ########.fr */
10
/* */
11
/* ************************************************************************** */
12
13
#include <stdlib.h>
14
23
int
ft_memcmp
(
const
void
*s1,
const
void
*s2,
size_t
n)
24
{
25
const
unsigned
char
*p1;
26
const
unsigned
char
*p2;
27
28
p1 = (
const
unsigned
char
*)s1;
29
p2 = (
const
unsigned
char
*)s2;
30
while
(n--)
31
{
32
if
(*p1 != *p2)
33
return
(*p1 - *p2);
34
p1++;
35
p2++;
36
}
37
return
(0);
38
}
ft_memcmp
int ft_memcmp(const void *s1, const void *s2, size_t n)
Compares two memory areas byte by byte.
Definition
ft_memcmp.c:23
src
ft_memcmp.c
Generated by
1.9.8