-
Notifications
You must be signed in to change notification settings - Fork 1
/
ft_memcmp.c
31 lines (28 loc) · 1.23 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
31
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_memcmp.c :+: :+: */
/* +:+ */
/* By: ksmorozo <ksmorozo@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2020/10/29 14:35:26 by ksmorozo #+# #+# */
/* Updated: 2021/07/07 12:17:21 by ksmorozo ######## odam.nl */
/* */
/* ************************************************************************** */
#include <stddef.h>
int ft_memcmp(const void *ptr1, const void *ptr2, size_t num)
{
size_t count;
unsigned char *buffer1;
unsigned char *buffer2;
count = 0;
buffer1 = (unsigned char *)ptr1;
buffer2 = (unsigned char *)ptr2;
while (count != num)
{
if (buffer1[count] != buffer2[count])
return (buffer1[count] - buffer2[count]);
count++;
}
return (0);
}