-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memcmp.c
31 lines (28 loc) · 1.22 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: tclement <tclement@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2020/04/18 13:40:01 by tclement #+# #+# */
/* Updated: 2020/05/11 12:12:09 by tclement ######## odam.nl */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_memcmp(const void *s1, const void *s2, size_t n)
{
size_t index;
unsigned const char *str1;
unsigned const char *str2;
str1 = (unsigned const char*)s1;
str2 = (unsigned const char*)s2;
index = 0;
while (index < n)
{
if (str1[index] != str2[index])
return (str1[index] - str2[index]);
index++;
}
return (0);
}