-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strcmp.c
35 lines (32 loc) · 1.18 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
31
32
33
34
35
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kacoulib <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/16 17:40:02 by kacoulib #+# #+# */
/* Updated: 2016/12/06 17:18:20 by kacoulib ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_strcmp(char *s1, char *s2)
{
int i;
unsigned char r1;
unsigned char r2;
i = 0;
while (s1[i] != '\0' || s2[i] != '\0')
{
r1 = s1[i];
r2 = s2[i];
if (r1 != r2)
return (r1 - r2);
if (r1 == '\0')
return (-r2);
if (r2 == '\0')
return (r1);
i++;
}
return (0);
}