-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_memcmp.c
More file actions
32 lines (29 loc) · 1.19 KB
/
ft_memcmp.c
File metadata and controls
32 lines (29 loc) · 1.19 KB
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
31
32
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bsousa-d <bsousa-d@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/06/13 16:56:48 by bsousa-d #+# #+# */
/* Updated: 2023/10/09 15:02:25 by bsousa-d ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_memcmp(const void *ptr1, const void *ptr2, size_t num)
{
const unsigned char *s1;
const unsigned char *s2;
s1 = (const unsigned char *)ptr1;
s2 = (const unsigned char *)ptr2;
if (num == 0)
return (0);
while (num--)
{
if (*s1 != *s2)
return (*s1 - *s2);
s1++;
s2++;
}
return (0);
}