-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_memcmp.c
26 lines (23 loc) · 1.15 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: yettabaa <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/06 21:44:08 by yettabaa #+# #+# */
/* Updated: 2022/10/24 00:46:31 by yettabaa ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_memcmp(const void *str1, const void *str2, size_t n)
{
size_t i;
i = 0;
if (!n)
return (0);
while (i < (n -1) && *(unsigned char *)(str1 + i)
== *(unsigned char *)(str2 + i))
i++;
return (*(unsigned char *)(str1 + i) - *(unsigned char *)(str2 + i));
}