libft
ft_memcmp.c
Go to the documentation of this file.
1 /* ************************************************************************** */
3 /* */
4 /* ::: :::::::: */
5 /* ft_memcmp.c :+: :+: :+: */
6 /* +:+ +:+ +:+ */
7 /* By: unite <marvin@42.fr> +#+ +:+ +#+ */
8 /* +#+#+#+#+#+ +#+ */
9 /* Created: 2019/09/05 19:03:58 by unite #+# #+# */
10 /* Updated: 2020/07/16 02:57:18 by unite ### ########.fr */
11 /* */
12 /* ************************************************************************** */
13 
14 #include "libft.h"
15 
20 int ft_memcmp(const void *s1, const void *s2, size_t n)
21 {
22  unsigned char *str1;
23  unsigned char *str2;
24  size_t i;
25 
26  i = 0;
27  str1 = (unsigned char *)s1;
28  str2 = (unsigned char *)s2;
29  while (i < n)
30  {
31  if (str1[i] - str2[i])
32  return (str1[i] - str2[i]);
33  i++;
34  }
35  return (0);
36 }
ft_memcmp
int ft_memcmp(const void *s1, const void *s2, size_t n)
Replicates behaviour of memcmp from libc.
Definition: ft_memcmp.c:20
libft.h