blob: 233d79652bea161e89292ff5903ea2189b563133 (
plain)
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
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/10/07 09:56:44 by cacharle #+# #+# */
/* Updated: 2020/01/17 10:54:15 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_memcmp(const void *s1, const void *s2, size_t n)
{
size_t i;
t_ftbyte *cast_s1;
t_ftbyte *cast_s2;
cast_s1 = (t_ftbyte*)s1;
cast_s2 = (t_ftbyte*)s2;
if (n == 0)
return (0);
i = -1;
while (++i < n)
if (cast_s1[i] != cast_s2[i])
return (cast_s1[i] - cast_s2[i]);
return (0);
}
|