-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_memcmp.c
More file actions
28 lines (25 loc) · 1.15 KB
/
ft_memcmp.c
File metadata and controls
28 lines (25 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
27
28
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: marvin <marvin@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/01/22 13:07:10 by bwebb #+# #+# */
/* Updated: 2019/05/30 11:58:51 by bwebb ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_memcmp(const void *str1, const void *str2, size_t n)
{
size_t i;
unsigned char *s1;
unsigned char *s2;
s1 = (unsigned char *)str1;
s2 = (unsigned char *)str2;
i = -1;
while (++i < n)
if (s1[i] != s2[i])
return (s1[i] - s2[i]);
return (0);
}