-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_memcmp.c
26 lines (23 loc) · 1.16 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dpylypen <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/24 13:01:35 by dpylypen #+# #+# */
/* Updated: 2016/12/02 17:41:27 by dpylypen ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_memcmp(const void *ptr1, const void *ptr2, size_t num)
{
unsigned char *ptr_1;
unsigned char *ptr_2;
ptr_1 = (unsigned char *)ptr1;
ptr_2 = (unsigned char *)ptr2;
while (num--)
if (*(ptr_1++) != *(ptr_2++))
return (*(--ptr_1) - *(--ptr_2));
return (0);
}