-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_memcmp.c
More file actions
39 lines (35 loc) · 1.34 KB
/
ft_memcmp.c
File metadata and controls
39 lines (35 loc) · 1.34 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
34
35
36
37
38
39
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sparth <sparth@student.42heilbronn.de> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/10 09:44:30 by sparth #+# #+# */
/* Updated: 2023/10/16 14:49:56 by sparth ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_memcmp(const void *s1, const void *s2, size_t n)
{
unsigned char *string1;
unsigned char *string2;
size_t i;
string1 = (unsigned char *) s1;
string2 = (unsigned char *) s2;
i = 0;
while (i < n)
{
if (string1[i] != string2[i])
return (string1[i] - string2[i]);
i++;
}
return (0);
}
// int main()
// {
// char string1 [] = "Helloo";
// char string2 [] = "Hello";
// printf("%d", memcmp(string1, string2, 6));
// return (0);
// }