-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_memcmp.c
More file actions
33 lines (30 loc) · 1.24 KB
/
ft_memcmp.c
File metadata and controls
33 lines (30 loc) · 1.24 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: iuslu <iuslu@student.42kocaeli.com.tr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/02/04 09:17:44 by iuslu #+# #+# */
/* Updated: 2026/02/04 09:17:47 by iuslu ### ########.fr */
/* */
/* ************************************************************************** */
#include <stddef.h>
int ft_memcmp(const void *s1, const void *s2, size_t n)
{
unsigned char *s1temp;
unsigned char *s2temp;
s1temp = (unsigned char *)s1;
s2temp = (unsigned char *)s2;
while (n > 0)
{
if (*s1temp > *s2temp)
return (*s1temp - *s2temp);
else if (*s1temp < *s2temp)
return (*s1temp - *s2temp);
s1temp++;
s2temp++;
n--;
}
return (0);
}