-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memcmp.c
30 lines (27 loc) · 1.2 KB
/
ft_memcmp.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: pabmart2 <[email protected] +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/11 13:58:41 by pabmart2 #+# #+# */
/* Updated: 2024/09/17 15:21:31 by pabmart2 ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_memcmp(const void *s1, const void *s2, size_t n)
{
const unsigned char *temp_s1;
const unsigned char *temp_s2;
temp_s1 = (const unsigned char *)s1;
temp_s2 = (const unsigned char *)s2;
while (n--)
{
if (*temp_s1 != *temp_s2)
return (*temp_s1 - *temp_s2);
++temp_s1;
++temp_s2;
}
return (0);
}