-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memcmp.c
35 lines (32 loc) · 1.25 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
32
33
34
35
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: snocita <snocita@student.42wolfsburg.de> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/17 16:19:51 by snocita #+# #+# */
/* Updated: 2023/01/11 12:21:43 by snocita ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/*
Compares the memory of the pointers byte by byte
returns the difference or 0 if identical
*/
int ft_memcmp(const void *s1, const void *s2, size_t n)
{
unsigned const char *t1;
unsigned const char *t2;
t1 = (unsigned const char *)s1;
t2 = (unsigned const char *)s2;
while (n)
{
if (*t1 != *t2)
return (*t1 - *t2);
t1++;
t2++;
n--;
}
return (0);
}