-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_memcmp.c
More file actions
37 lines (33 loc) · 1.39 KB
/
ft_memcmp.c
File metadata and controls
37 lines (33 loc) · 1.39 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
29
30
31
32
33
34
35
36
37
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_memcmp.c :+: :+: */
/* +:+ */
/* By: farodrig <farodrig@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2020/12/04 11:47:46 by farodrig #+# #+# */
/* Updated: 2020/12/12 18:48:12 by farodrig ######## odam.nl */
/* */
/* ************************************************************************** */
#include "libft.h"
/*
** Compares byte string str1 against byte string str2. Both strings
** are assumed to be len bytes long. Returns zero if the two strings are
** identical, otherwise returns the difference between the first two differing
** bytes.
*/
int ft_memcmp(const void *str1, const void *str2, size_t len)
{
size_t i;
i = 0;
while (len)
{
if (((unsigned char *)str1)[i] != ((unsigned char *)str2)[i])
{
return (((unsigned char *)str1)[i] - ((unsigned char *)str2)[i]);
}
i++;
len--;
}
return (0);
}