-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathft_memcmp.c
31 lines (28 loc) · 1.17 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: tsomsa <tsomsa@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/02/22 21:49:43 by tsomsa #+# #+# */
/* Updated: 2022/02/22 21:49:45 by tsomsa ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_memcmp(const void *str1, const void *str2, size_t n)
{
unsigned char *buf1;
unsigned char *buf2;
buf1 = (unsigned char *) str1;
buf2 = (unsigned char *) str2;
while (n > 0)
{
if (*buf1 != *buf2)
return (*buf1 - *buf2);
buf1++;
buf2++;
n--;
}
return (0);
}