-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_memcmp.c
More file actions
26 lines (23 loc) · 1.15 KB
/
Copy pathft_memcmp.c
File metadata and controls
26 lines (23 loc) · 1.15 KB
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: ophuong <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/09/08 15:26:01 by ophuong #+# #+# */
/* Updated: 2019/09/10 15:30:17 by ophuong ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_memcmp(const void *s1, const void *s2, size_t n)
{
size_t id;
id = 0;
if (n == 0)
return (0);
while (id < (n - 1) &&
((unsigned char *)s1)[id] == ((unsigned char *)s2)[id])
id++;
return (((unsigned char *)s1)[id] - ((unsigned char *)s2)[id]);
}