-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_memcmp.c
30 lines (27 loc) · 1.19 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: aelsayed <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/22 12:29:43 by aelsayed #+# #+# */
/* Updated: 2024/11/03 22:30:58 by aelsayed ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_memcmp(void const *str1, void const *str2, size_t n)
{
unsigned char const *s1;
unsigned char const *s2;
s1 = (unsigned char const *)str1;
s2 = (unsigned char const *)str2;
while (n--)
{
if (*s1 != *s2)
return (*s1 - *s2);
s1++;
s2++;
}
return (0);
}