-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memcmp.c
29 lines (26 loc) · 1.19 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lenzo-pe <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/02/05 15:48:09 by lenzo-pe #+# #+# */
/* Updated: 2021/05/07 14:56:32 by lenzo-pe ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_string.h"
int ft_memcmp(const void *ptr1, const void *ptr2, size_t num)
{
unsigned int i;
unsigned char *str1;
unsigned char *str2;
i = 0;
str1 = (unsigned char *)ptr1;
str2 = (unsigned char *)ptr2;
if (num == 0)
return (0);
while (str1[i] == str2[i] && --num)
i++;
return (str1[i] - str2[i]);
}