-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strcmp.c
28 lines (25 loc) · 1.24 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ashongwe <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/05/24 12:47:34 by ashongwe #+# #+# */
/* Updated: 2019/06/14 07:37:19 by ashongwe ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_strcmp(const char *s1, const char *s2)
{
size_t control;
control = 0;
while (s1[control] && s2[control] && s1[control] == s2[control])
control++;
if (((unsigned char)s1[control] - (unsigned char)s2[control]) < 0)
return (-1);
else if (((unsigned char)s1[control] - (unsigned char)s2[control]) > 0)
return (1);
else
return (0);
}