-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_memcmp.c
More file actions
29 lines (26 loc) · 870 Bytes
/
ft_memcmp.c
File metadata and controls
29 lines (26 loc) · 870 Bytes
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: dyanar <dyanar@student.42istanbul.com.tr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/02/04 20:38:50 by dyanar #+# #+# */
/* Updated: 2026/02/04 20:38:50 by dyanar ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_memcmp(const void *s1, const void *s2, size_t n)
{
unsigned char *b1;
unsigned char *b2;
size_t i;
if (n == 0)
return (0);
b1 = (unsigned char *)s1;
b2 = (unsigned char *)s2;
i = 0;
while (b1[i] == b2[i] && n-- > 1)
i++;
return (b1[i] - b2[i]);
}