-
Notifications
You must be signed in to change notification settings - Fork 4
/
ft_memcmp.c
25 lines (22 loc) · 1.07 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ykoh <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/03/17 20:51:59 by ykoh #+# #+# */
/* Updated: 2020/04/11 00:02:26 by ykoh ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_memcmp(const void *s1, const void *s2, size_t n)
{
int res;
while (n--)
{
if ((res = *((unsigned char *)s1++) - *((unsigned char *)s2++)))
return (res);
}
return (0);
}