-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strcmp.c
30 lines (28 loc) · 1.17 KB
/
ft_strcmp.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
30
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: averemiy <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/03/22 15:40:32 by averemiy #+# #+# */
/* Updated: 2018/04/02 19:15:01 by averemiy ### ########.fr */
/* */
/* ************************************************************************** */
int ft_strcmp(const char *s1, const char *s2)
{
unsigned char *p2;
unsigned char *p1;
p1 = (unsigned char *)s1;
p2 = (unsigned char *)s2;
while (*p1 != '\0' || *p2 != '\0')
{
if (*p1 > *p2)
return (*p1 - *p2);
if (*p2 > *p1)
return (-1 * (*p2 - *p1));
p1++;
p2++;
}
return (0);
}